Skip to content

Commit

Permalink
fix: Support reading cspell.config.js files (#861)
Browse files Browse the repository at this point in the history
* fix: Support reading cspell.config.js files
  - Do not WebPack `import-fresh`
  • Loading branch information
Jason3S authored May 13, 2021
1 parent bf7093c commit 56412f8
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 3 deletions.
13 changes: 13 additions & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,24 @@
**/.DS_Store
!CHANGELOG.md
!images/SpellCheck.png

# Dictionaries cannot be WebPacked
!node_modules/@cspell/cspell-bundled-dicts/**
!node_modules/@cspell/dict*/**/{README.md,LICENSE}
!node_modules/@cspell/dict*/**/*.{json,gz}

# Regexp worker must NOT be WebPacked
!node_modules/regexp-worker/**/{LICENSE,package.json,README.md}
!node_modules/regexp-worker/**/*.js

# Do not WebPack import-fresh and dependencies
# This is needed to support cosmiconfig
!node_modules/import-fresh/**
!node_modules/resolve-from/**
!node_modules/parent-module/**
!node_modules/callsites/**

# All Other Client and Server files.
!packages/_server/dist/api.js
!packages/_server/dist/main.js
!packages/_server/dist/main.js.LICENSE.txt
Expand Down
2 changes: 2 additions & 0 deletions cSpell.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"temp",
"languageCodes.ts",
"samples",
".vscodeignore",
"cSpell.json",
"fixtures/workspaces/**",
"**/__snapshots__/**",
"packages/client/settingsViewer/**",
Expand Down
1 change: 1 addition & 0 deletions cspell-words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ appid
arraylength
cfml
colorscheme
cosmiconfig
darkblue
dcopy
devtool
Expand Down
8 changes: 8 additions & 0 deletions fixtures/workspaces/js-config/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Single Workspace

This Workspace only contains the current directory as a folder.

WORKSPACEWORD - a word only in the workspace.

Terms:
customterm - Added to Custom Terms.
Empty file.
20 changes: 20 additions & 0 deletions fixtures/workspaces/js-config/cspell.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

/** @type { import("@cspell/cspell-types").CSpellUserSettings } */
const cspell = {
description: 'js-config example',
languageSettings: [
],
allowCompoundWords: false,
dictionaryDefinitions: [
{
name: 'custom-terms',
path: './custom-terms.txt',
scope: 'workspace',
addWords: true
},
],
dictionaries: ['custom-terms'],
};

module.exports = cspell;
2 changes: 2 additions & 0 deletions fixtures/workspaces/js-config/custom-terms.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
WORKSPACEWORD
customterm
17 changes: 17 additions & 0 deletions fixtures/workspaces/js-config/js-config.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"folders": [
{
"path": "."
}
],
"settings": {
"cSpell.customWorkspaceDictionaries": [
{
"addWords": true,
"description": "Alternate dictionary 2",
"name": "alt-terms",
"path": "${workspaceFolder}/alt-words.txt"
}
]
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -720,6 +720,7 @@
"dependencies": {
"@cspell/cspell-bundled-dicts": "^5.4.0",
"@cspell/cspell-types": "^5.4.0",
"cosmiconfig": "^7.0.0",
"regexp-worker": "^1.1.0"
}
}
2 changes: 1 addition & 1 deletion packages/_server/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"port": 60048,
"sourceMaps": true,
"outFiles": [
"${workspaceRoot}/../client/server/**/*.js"
"${workspaceRoot}/dist/**/*.js"
],
"protocol": "inspector"
}
Expand Down
2 changes: 1 addition & 1 deletion packages/_server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
"clean-build-production": "yarn run clean && yarn run compile",
"build-production": "yarn run clean-build-production",
"compile": "yarn run webpack",
"watch": "yarn run installServerIntoExtension && tsc --watch -p .",
"watch": "yarn run build --watch",
"webpack": "webpack -c webpack.prod.js",
"webpack-dev": "webpack -c webpack.dev.js",
"test-watch": "jest --watch",
Expand Down
1 change: 1 addition & 0 deletions packages/_server/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module.exports = {
externals: [
/^regexp-worker/, // pulled out so the worker can be loaded correctly.
/^@cspell\/cspell-bundled-dicts/,
/^import-fresh/, // Do not bundle `import-fresh` which is used by `cosmiconfig` to load cspell.config.js files.
],
output: {
path: path.resolve(__dirname, 'dist'),
Expand Down
2 changes: 1 addition & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"lint": "eslint 'src/**'",
"vscode:prepublish": "yarn run build-production",
"version": "yarn run package-extension",
"watch": "yarn run build -- --watch",
"watch": "yarn run build --watch",
"test": "jest",
"test-integration": "cross-env CODE_DISABLE_EXTENSIONS=true CODE_TESTS_PATH=./../_integrationTests/out CODE_TESTS_DATA_DIR=./temp/vscode node ../_integrationTests/integrationTestRunner",
"test-watch": "jest --watch"
Expand Down

0 comments on commit 56412f8

Please sign in to comment.