Skip to content

Commit

Permalink
Fix vsix bundle size
Browse files Browse the repository at this point in the history
Merge in ADGUARD-FILTERS/vscode-adblock-syntax from fix-vsix-size to master

Squashed commit of the following:

commit bc41b9b
Merge: 43566f0 993aa35
Author: scripthunter7 <[email protected]>
Date:   Wed Jan 10 17:49:46 2024 +0100

    Merge branch 'master' into fix-vsix-size

commit 43566f0
Author: scripthunter7 <[email protected]>
Date:   Wed Jan 10 13:12:17 2024 +0100

    Update scripts in contributing guides

commit f75137a
Author: scripthunter7 <[email protected]>
Date:   Wed Jan 10 13:11:49 2024 +0100

    Improve scripts in package.json

commit 199e442
Author: scripthunter7 <[email protected]>
Date:   Tue Jan 9 20:02:38 2024 +0100

    Remove unnecessary externals

commit e8085e4
Author: scripthunter7 <[email protected]>
Date:   Tue Jan 9 19:56:05 2024 +0100

    Better path handling

commit 7865f81
Author: scripthunter7 <[email protected]>
Date:   Tue Jan 9 19:49:46 2024 +0100

    Update esbuild commands

commit 783ca87
Author: scripthunter7 <[email protected]>
Date:   Tue Jan 9 19:47:41 2024 +0100

    Re-export AGTree from a separate file
  • Loading branch information
scripthunter7 committed Jan 10, 2024
1 parent 993aa35 commit f1034d9
Show file tree
Hide file tree
Showing 5 changed files with 211 additions and 30 deletions.
27 changes: 19 additions & 8 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,23 @@ To create a production build of the extension:

During development, you can use the following commands (listed in `package.json`).

- `yarn build:grammar` - Builds a PList version of the TM grammar, because VSCode does not support YAML grammars
directly.
- `yarn build:prod` - Create a production build of the extension. This will also generate a `.vsix` file in the `out`
folder.
- `yarn build:txt` - Creates a `build.txt` file in the `out` folder that includes the current version number. Typically,
this is used by CI.
- `yarn build:vsix` - Generate a `.vsix` file in the `out` folder. This file can be installed in VSCode as an extension.
- `yarn clean` - Clean output folders (build results).
- `yarn build:grammar` - Compiles the TextMate (TM) grammar into a PList format, since VSCode does not natively support
YAML grammars.
- `yarn build:prod` - Generates a production build of the extension, including a `.vsix` file in the `out` directory for
VSCode installation.
- `yarn build:txt` - Creates a `build.txt` file in the out directory containing the current version number, primarily
for Continuous Integration (CI) purposes.
- `yarn build:vsix` - Produces a `.vsix` file in the out directory, which is used to install the extension in VSCode.
- `yarn clean` - Removes all generated files in the output directories, cleaning up the build results.
- `yarn esbuild:aglint` - Base ESBuild command for building integrated AGLint with the common options.
- `yarn esbuild:agtree` - Base ESBuild command for building integrated AGTree with the common options.
Integrated AGTree comes with the integrated AGLint, this command just helps to bundle it to a separate file.
This is needed because AGTree is also used by the server, and by bundling it to a separate file, we can avoid
double-bundling AGTree.
- `yarn esbuild:server` - Base ESBuild command for building the server with the common options.
- `yarn esbuild:client` - Base ESBuild command for building the client with the common options.
- `yarn extract-changelog` - Extract changes from the `CHANGELOG.md` for a specific version. Typically, this is used by
CI.
- `yarn increment` - Increment the patch version number of the extension in the `package.json` file. Typically, this is
used by CI.
- `yarn lint:md` - Lint the markdown files with [markdownlint][markdownlint].
Expand All @@ -130,6 +139,8 @@ During development, you can use the following commands (listed in `package.json`
- `yarn lint` - Run all linters.
- `yarn test:compile` - Check if the code compiles with [TypeScript][typescript].
- `yarn test` - Run tests with [Jest][jest].
- `yarn watch:aglint` - Watch for changes in the AGLint code and create a development build automatically.
- `yarn watch:agtree` - Watch for changes in the AGTree code and create a development build automatically.
- `yarn watch:client` - Watch for changes in the client code and create a development build automatically.
- `yarn watch:grammar` - Watch for changes in the TM grammar and rebuild it automatically.
- `yarn watch:server` - Watch for changes in the server code and create a development build automatically.
Expand Down
20 changes: 13 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,15 @@
}
},
"scripts": {
"build:grammar": "ts-node tools/grammar-builder.ts",
"build:prod": "yarn clean && yarn build:grammar && yarn test:compile && esbuild ./client/src/extension.ts --bundle --outfile=client/out/extension.js --external:vscode --format=cjs --platform=node --minify && yarn esbuild ./server/src/server.ts --bundle --outfile=server/out/server.js --external:vscode --external:\"./integrated-aglint\" --format=cjs --platform=node --minify && yarn esbuild ./server/src/aglint.ts --bundle --outfile=server/out/aglint.js --format=cjs --platform=node --minify && yarn build:vsix",
"build:txt": "ts-node-esm tools/build-txt.ts",
"build:grammar": "tsx tools/grammar-builder.ts",
"build:prod": "yarn clean && yarn build:grammar && yarn test:compile && yarn esbuild:client --minify && yarn esbuild:agtree --minify && yarn esbuild:aglint --minify && yarn esbuild:server --minify && yarn build:vsix",
"build:txt": "tsx tools/build-txt.ts",
"build:vsix": "mkdirp out && vsce package --yarn --out out/vscode-adblock.vsix",
"clean": "rimraf ./client/out && rimraf ./server/out && rimraf ./syntaxes/out && rimraf ./out",
"esbuild:aglint": "esbuild ./server/src/aglint.ts --bundle --outfile=server/out/aglint.js --format=cjs --platform=node --alias:@adguard/agtree=./agtree --external:./agtree",
"esbuild:agtree": "esbuild ./server/src/agtree.ts --bundle --outfile=server/out/agtree.js --format=cjs --platform=node",
"esbuild:client": "esbuild ./client/src/extension.ts --bundle --outfile=client/out/extension.js --format=cjs --platform=node --external:vscode",
"esbuild:server": "esbuild ./server/src/server.ts --bundle --outfile=server/out/server.js --format=cjs --platform=node --external:vscode --external:./agtree",
"extract-changelog": "node -r esbuild-register tools/changelog-extractor.ts",
"increment": "yarn version --patch --no-git-tag-version",
"lint": "yarn lint:ts && yarn lint:md",
Expand All @@ -107,10 +111,11 @@
"prepare": "husky install",
"test": "jest",
"test:compile": "tsc -p ./client --noEmit && tsc -p ./server --noEmit",
"watch:aglint": "esbuild ./server/src/aglint.ts --bundle --outfile=server/out/aglint.js --format=cjs --platform=node --sourcemap --watch",
"watch:client": "esbuild ./client/src/extension.ts --bundle --outfile=client/out/extension.js --external:vscode --format=cjs --platform=node --sourcemap --watch",
"watch:grammar": "sane \"ts-node tools/grammar-builder.ts\" --glob=syntaxes/adblock.yaml-tmlanguage",
"watch:server": "esbuild ./server/src/server.ts --bundle --outfile=server/out/server.js --external:vscode --external:./integrated-aglint --format=cjs --platform=node --sourcemap --watch"
"watch:aglint": "yarn esbuild:aglint --sourcemap --watch",
"watch:agtree": "yarn esbuild:agtree --sourcemap --watch",
"watch:client": "yarn esbuild:client --sourcemap --watch",
"watch:grammar": "sane \"tsx tools/grammar-builder.ts\" --glob=syntaxes/adblock.yaml-tmlanguage",
"watch:server": "yarn esbuild:server --sourcemap --watch"
},
"devDependencies": {
"@swc/core": "^1.3.76",
Expand Down Expand Up @@ -149,6 +154,7 @@
"sane": "^5.0.1",
"ts-jest": "^29.1.0",
"ts-node": "^10.9.1",
"tsx": "^4.7.0",
"typescript": "^4.9.5",
"unified": "^11.0.4",
"vscode-oniguruma": "^1.7.0",
Expand Down
5 changes: 5 additions & 0 deletions server/src/agtree.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/**
* @file Export AGTree API
*/

export * from '@adguard/agtree';
2 changes: 1 addition & 1 deletion server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ import { fileURLToPath, pathToFileURL } from 'url';
import { satisfies } from 'semver';
// Import type definitions from the AGLint package
import type * as AGLint from '@adguard/aglint';
import { ConfigCommentRuleParser, type ConfigCommentRule, CommentMarker } from '@adguard/agtree';
import cloneDeep from 'clone-deep';

import { ConfigCommentRuleParser, type ConfigCommentRule, CommentMarker } from './agtree';
import { getErrorMessage } from './utils/error';
import { resolveAglintModulePath } from './utils/aglint-resolver';
import {
Expand Down
Loading

0 comments on commit f1034d9

Please sign in to comment.