Skip to content

Commit

Permalink
fix: Use webpack on the server to reduce file size. (#679)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason3S authored Jan 25, 2021
1 parent de4bf2f commit e1d0bc7
Show file tree
Hide file tree
Showing 12 changed files with 10,348 additions and 769 deletions.
10,111 changes: 9,570 additions & 541 deletions packages/_server/package-lock.json

Large diffs are not rendered by default.

31 changes: 18 additions & 13 deletions packages/_server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,31 @@
"@types/jest": "^26.0.19",
"@types/micromatch": "^4.0.1",
"@types/node": "^12.19.12",
"jest": "^26.6.3",
"jest-diff": "^26.6.2",
"lorem-ipsum": "^2.0.3",
"ts-jest": "^26.4.4",
"ts-json-schema-generator": "^0.78.0",
"typescript": "^4.1.3"
},
"dependencies": {
"cspell-glob": "^5.1.3",
"cspell-lib": "^5.1.3",
"cspell-glob": "^5.2.0",
"cspell-lib": "^5.2.1",
"fs-extra": "^9.0.1",
"gensequence": "^3.1.1",
"iconv-lite": "^0.6.2",
"jest": "^26.6.3",
"jest-diff": "^26.6.2",
"lorem-ipsum": "^2.0.3",
"micromatch": "^4.0.2",
"minimatch": "^3.0.4",
"node-watch": "^0.7.1",
"regexp-worker": "^1.1.0",
"rxjs": "^6.6.2",
"ts-jest": "^26.4.4",
"ts-json-schema-generator": "^0.78.0",
"ts-loader": "^8.0.12",
"typescript": "^4.1.3",
"vscode-languageserver": "^7.0.0",
"vscode-languageserver-textdocument": "^1.0.1",
"vscode-uri": "^3.0.2"
"vscode-uri": "^3.0.2",
"webpack": "^5.11.0",
"webpack-cli": "^4.2.0"
},
"dependencies": {
"@cspell/cspell-bundled-dicts": "^5.2.0"
},
"scripts": {
"clean": "rimraf ../client/server && rimraf ./tools/out",
Expand All @@ -47,9 +51,10 @@
"installServerIntoExtension": "node installServer ../client/server ./package.json ./tsconfig.json",
"clean-build": "npm run clean && npm run build",
"clean-build-production": "npm run clean && npm run compile",
"compile": "tsc -p .",
"compile": "npm run webpack",
"watch": "npm run installServerIntoExtension && tsc --watch -p .",
"tsc": "tsc -p .",
"webpack": "webpack -c webpack.prod.js",
"webpack-dev": "webpack -c webpack.dev.js",
"test-watch": "jest --watch",
"test": "jest"
}
Expand Down
2 changes: 2 additions & 0 deletions packages/_server/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import * as config from './config/cspellConfig';

export * from './config/cspellConfig';

export interface GetConfigurationForDocumentResult {
languageEnabled: boolean | undefined;
fileEnabled: boolean | undefined;
Expand Down
16 changes: 10 additions & 6 deletions packages/_server/src/config/cspellConfig.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
// Export the cspell settings to the client.

import * as cspell from 'cspell-lib';
import { DictionaryId, FsPath } from 'cspell-lib';
import {
DictionaryId,
FsPath,
DictionaryFileTypes,
CSpellSettings,
CSpellUserSettingsWithComments as CSpellLibUserSettingsWithComments,
} from 'cspell-lib';
export { LanguageSetting, DictionaryDefinition, DictionaryFileTypes } from 'cspell-lib';

export const defaultDictionaryType: cspell.DictionaryFileTypes = 'S';
export const defaultDictionaryType: DictionaryFileTypes = 'S';

export interface SpellCheckerSettings {
/**
Expand Down Expand Up @@ -63,7 +68,6 @@ export interface SpellCheckerSettings {
*/
showCommandsInEditorContextMenu?: boolean;


/**
* @title File Types to Check
* @scope resource
Expand Down Expand Up @@ -192,7 +196,7 @@ export interface CustomDictionary {
addWords?: boolean;
}

export interface CSpellUserSettingsWithComments extends cspell.CSpellUserSettingsWithComments, SpellCheckerSettings {}
export interface CSpellUserSettings extends cspell.CSpellSettings, SpellCheckerSettings {}
export interface CSpellUserSettingsWithComments extends CSpellLibUserSettingsWithComments, SpellCheckerSettings {}
export interface CSpellUserSettings extends CSpellSettings, SpellCheckerSettings {}

export type SpellCheckerSettingsProperties = keyof SpellCheckerSettings;
2 changes: 0 additions & 2 deletions packages/_server/src/index.ts

This file was deleted.

37 changes: 37 additions & 0 deletions packages/_server/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require('path');

module.exports = {
entry: {
server: './src/server.ts',
api: './src/api.ts'
},
target: 'node',
module: {
rules: [
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
}
],
},
resolve: {
extensions: ['.tsx', '.ts', '.js'],
},
node: {
__filename: false,
__dirname: false,
},
externalsType: 'commonjs-module',
externalsPresets: {
node: true,
},
externals: [
/^@cspell\/cspell-bundled-dicts/,
],
output: {
path: path.resolve(__dirname, '../client/server'),
filename: '[name].js',
},
};
7 changes: 7 additions & 0 deletions packages/_server/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const config = require('./webpack.config');

module.exports = {
...config,
devtool: 'source-map',
};
8 changes: 8 additions & 0 deletions packages/_server/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const config = require('./webpack.config');

module.exports = {
...config,
devtool: 'source-map',
mode: 'production',
};
Loading

0 comments on commit e1d0bc7

Please sign in to comment.