Skip to content

Commit

Permalink
chore: get it back working in browser
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeart committed Oct 16, 2021
1 parent c448127 commit 5b7bc85
Show file tree
Hide file tree
Showing 6 changed files with 900 additions and 38 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,12 @@ jobs:
env:
VERSION: "${{ steps.gitversion.outputs.majorMinorPatch }}"

- name: compile
- name: compile for node
run: yarn node:package

- name: compile for worker
run: yarn web:package

- name: compile and create vsix
run: yarn vs:package

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules
out
.vscode-test-web
1 change: 1 addition & 0 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
vscode-glimmer-syntax*
.github
.vscode
.vscode-test-web
src
.gitignore
webpack.config.js
Expand Down
55 changes: 30 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,22 @@
"Syntax"
],
"activationEvents": [
"onLanguage:javascript",
"onLanguage:typescript"
],
"onLanguage:javascript",
"onLanguage:typescript"
],
"main": "./out/index.js",
"browser": "./out/worker.js",
"scripts": {
"vscode:prepublish": "yarn node:package",
"compile": "tsc -p ./",
"watch": "tsc -w -p ./",
"vscode:prepublish": "yarn node:package && yarn web:package",
"compile": "tsc -p ./",
"watch": "tsc -w -p ./",
"vs:package": "vsce package --yarn",
"vs:publish": "vsce publish --yarn",
"vs:publish:ci": "vsce publish --yarn --pat $VSCODE_STORE_TOKEN",
"ov:publish:ci": "ovsx publish --yarn --pat $OPEN_VSX_STORE_TOKEN",
"node:package": "webpack --mode production"
"node:package": "webpack --mode production",
"web:package": "webpack --mode production",
"chrome": "vscode-test-web --browserType=chromium --extensionDevelopmentPath=."
},
"extensionKind": [
"ui"
Expand Down Expand Up @@ -93,21 +96,21 @@
}
],
"typescriptServerPlugins": [
{
"name": "typescript-hbs-plugin",
"enableForWorkspaceTypeScriptVersions": true
}
],
"jsonValidation": [
{
"fileMatch": "jsconfig*.json",
"url": "./schemas/tsconfig.schema.json"
},
{
"fileMatch": "tsconfig*.json",
"url": "./schemas/tsconfig.schema.json"
}
]
{
"name": "typescript-hbs-plugin",
"enableForWorkspaceTypeScriptVersions": true
}
],
"jsonValidation": [
{
"fileMatch": "jsconfig*.json",
"url": "./schemas/tsconfig.schema.json"
},
{
"fileMatch": "tsconfig*.json",
"url": "./schemas/tsconfig.schema.json"
}
]
},
"volta": {
"node": "12.20.1",
Expand All @@ -117,12 +120,14 @@
"typescript-hbs-plugin": "^0.1.1"
},
"devDependencies": {
"ovsx": "^0.2.1",
"vsce": "1.100.1",
"@types/node": "^12.7.5",
"@types/vscode": "^1.31.0",
"@types/vscode": "^1.31.0",
"@vscode/test-web": "^0.0.15",
"ovsx": "^0.2.1",
"path-browserify": "^1.0.1",
"ts-loader": "^9.2.3",
"typescript": "^4.1.3",
"vsce": "1.100.1",
"webpack": "^5.44.0",
"webpack-cli": "^4.7.2"
}
Expand Down
42 changes: 42 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,49 @@ const nodeClientConfig = /** @type WebpackConfig */ {
};


const browserClientConfig = /** @type WebpackConfig */ {
context: path.join(__dirname),
mode: 'none',
target: 'webworker', // web extensions run in a webworker context
entry: {
worker: './src/index.ts',
},
output: {
filename: '[name].js',
path: path.join(__dirname, 'out'),
libraryTarget: 'commonjs',
},
resolve: {
mainFields: ['module', 'main'],
extensions: ['.ts', '.js'], // support ts-files and js-files
fallback: {
path: require.resolve('path-browserify'),
},
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
},
],
},
],
},
externals: {
vscode: 'commonjs vscode', // ignored because it doesn't exist
},
performance: {
hints: false,
},
// devtool: 'source-map',
};

const bundles = [
{ name: 'web:package', config: browserClientConfig },
{ name: 'node:package', config: nodeClientConfig }
]

Expand Down
Loading

0 comments on commit 5b7bc85

Please sign in to comment.