diff --git a/.scripts/release.mjs b/.scripts/release.mjs index 786646e5..2a82e71b 100644 --- a/.scripts/release.mjs +++ b/.scripts/release.mjs @@ -22,6 +22,7 @@ async function call(command) { async function run() { await call(`git checkout main`); await call(`git pull`); + await call(`npm run clean`); await call(`npm clean-install`); await call(`npm run build`); await call(`npm run release`); diff --git a/package-lock.json b/package-lock.json index ff02f117..2230d969 100644 --- a/package-lock.json +++ b/package-lock.json @@ -23805,7 +23805,7 @@ "some-sass-language-server": "1.8.3", "vscode-css-languageservice": "6.3.1", "vscode-languageclient": "9.0.1", - "vscode-uri": "3.0.7" + "vscode-uri": "3.0.8" }, "devDependencies": { "@types/mocha": "10.0.7", @@ -23843,10 +23843,6 @@ "engines": { "node": ">= 6" } - }, - "vscode-extension/node_modules/vscode-uri": { - "version": "3.0.7", - "license": "MIT" } } } diff --git a/packages/language-server/bin/some-sass-language-server b/packages/language-server/bin/some-sass-language-server index 04932a4b..90e12734 100755 --- a/packages/language-server/bin/some-sass-language-server +++ b/packages/language-server/bin/some-sass-language-server @@ -6,7 +6,10 @@ const args = process.argv; if (args.includes("--version") || args.includes("-v") || args.includes("-V")) { try { - const pkg = fs.readFileSync(path.join(__dirname, "..", "package.json"), "utf-8"); + const pkg = fs.readFileSync( + path.join(__dirname, "..", "package.json"), + "utf-8", + ); const json = JSON.parse(pkg); if (!json.version) { throw new Error(); @@ -25,4 +28,4 @@ For documentation, visit https://wkillerud.github.io/some-sass/language-server/g return; } -require(path.join(__dirname, "..", "dist", "node-server.js")); +require(path.join(__dirname, "..", "dist", "node-main.js")); diff --git a/packages/language-server/rspack.browser.config.js b/packages/language-server/rspack.browser.config.js index ec76cd4f..652bc135 100644 --- a/packages/language-server/rspack.browser.config.js +++ b/packages/language-server/rspack.browser.config.js @@ -8,7 +8,7 @@ const config = { context: __dirname, target: "webworker", entry: { - "browser-server": "./src/browser-server.ts", + "browser-main": "./src/browser-main.ts", }, output: { libraryTarget: "var", @@ -42,6 +42,7 @@ const config = { resolve: { extensions: [".ts", ".js"], mainFields: ["browser", "module", "main"], + conditionNames: ["import", "require", "default"], fallback: { events: require.resolve("events/"), path: require.resolve("path-browserify"), @@ -54,6 +55,9 @@ const config = { new rspack.ProvidePlugin({ process: "process/browser", }), + new rspack.optimize.LimitChunkCountPlugin({ + maxChunks: 1, + }), // Only register the plugin when RSDOCTOR is true, as the plugin will increase the build time. process.env.RSDOCTOR && new RsdoctorRspackPlugin(), ].filter(Boolean), diff --git a/packages/language-server/rspack.node.config.js b/packages/language-server/rspack.node.config.js index 3b3c971c..63c35b6a 100644 --- a/packages/language-server/rspack.node.config.js +++ b/packages/language-server/rspack.node.config.js @@ -7,7 +7,7 @@ const { RsdoctorRspackPlugin } = require("@rsdoctor/rspack-plugin"); const config = { target: "node", entry: { - "node-server": "./src/node-server.ts", + "node-main": "./src/node-main.ts", }, output: { filename: "[name].js", @@ -16,6 +16,8 @@ const config = { }, resolve: { extensions: [".ts", ".js"], + conditionNames: ["import", "require", "default"], + mainFields: ["module", "main"], }, module: { rules: [ diff --git a/packages/language-server/src/browser-main.ts b/packages/language-server/src/browser-main.ts new file mode 100644 index 00000000..8f8f229b --- /dev/null +++ b/packages/language-server/src/browser-main.ts @@ -0,0 +1,4 @@ +async function setupBrowser() { + await import("./browser-server"); +} +setupBrowser(); diff --git a/packages/language-server/src/node-main.ts b/packages/language-server/src/node-main.ts new file mode 100644 index 00000000..d7b93a66 --- /dev/null +++ b/packages/language-server/src/node-main.ts @@ -0,0 +1,4 @@ +async function setupNode() { + await import("./node-server"); +} +setupNode(); diff --git a/packages/vscode-css-languageservice/src/tsconfig.esm.json b/packages/vscode-css-languageservice/src/tsconfig.esm.json index bc6eaa7a..99a4c613 100644 --- a/packages/vscode-css-languageservice/src/tsconfig.esm.json +++ b/packages/vscode-css-languageservice/src/tsconfig.esm.json @@ -4,6 +4,7 @@ "module": "es6", "moduleResolution": "node", "sourceMap": true, + "inlineSourceMap": false, "declaration": true, "strict": true, "stripInternal": true, diff --git a/packages/vscode-css-languageservice/src/tsconfig.json b/packages/vscode-css-languageservice/src/tsconfig.json index fce46f01..f0b3655d 100644 --- a/packages/vscode-css-languageservice/src/tsconfig.json +++ b/packages/vscode-css-languageservice/src/tsconfig.json @@ -4,6 +4,7 @@ "module": "umd", "moduleResolution": "node", "sourceMap": true, + "inlineSourceMap": false, "declaration": true, "strict": true, "stripInternal": true, diff --git a/vscode-extension/package.json b/vscode-extension/package.json index 5bdbcb8b..4bc23b8e 100644 --- a/vscode-extension/package.json +++ b/vscode-extension/package.json @@ -1371,7 +1371,7 @@ "some-sass-language-server": "1.8.3", "vscode-css-languageservice": "6.3.1", "vscode-languageclient": "9.0.1", - "vscode-uri": "3.0.7" + "vscode-uri": "3.0.8" }, "devDependencies": { "@types/mocha": "10.0.7", @@ -1392,6 +1392,8 @@ "build:development:browser": "npm run build:browser -- --mode=development", "build:production:node": "npm run build:node -- --mode=production", "build:production:browser": "npm run build:browser -- --mode=production", + "doctor:node": "RSDOCTOR=true run-s build:production:node", + "doctor:browser": "RSDOCTOR=true run-s build:production:browser", "start:web": "vscode-test-web --browserType=chromium --extensionDevelopmentPath=.", "lint": "eslint \"**/*.ts\" --cache", "pretest:e2e": "run-s clean build:production:*", diff --git a/vscode-extension/rspack.browser.config.js b/vscode-extension/rspack.browser.config.js index 780e87c0..8e5f7ed1 100644 --- a/vscode-extension/rspack.browser.config.js +++ b/vscode-extension/rspack.browser.config.js @@ -12,10 +12,9 @@ const config = { "browser-client": "./src/browser-client.ts", }, output: { - libraryTarget: "commonjs", - - path: path.join(__dirname, "./dist"), filename: "[name].js", + path: path.join(__dirname, "./dist"), + libraryTarget: "commonjs", }, externals: { vscode: "commonjs vscode", @@ -24,8 +23,8 @@ const config = { devtool: false, resolve: { extensions: [".ts", ".js"], - - mainFields: ["browser", "module", "main"], // prefer `browser` entry point in imported modules + mainFields: ["browser", "module", "main"], + conditionNames: ["import", "require", "default"], fallback: { events: require.resolve("events/"), assert: require.resolve("assert"), @@ -55,23 +54,27 @@ const config = { }, ], }, -}; - -module.exports = (env, argv) => { - config.plugins?.push( + plugins: [ new rspack.ProvidePlugin({ process: "process/browser", }), + new rspack.optimize.LimitChunkCountPlugin({ + maxChunks: 1, + }), new rspack.CopyRspackPlugin({ patterns: [ { - from: "../node_modules/some-sass-language-server/dist/browser-server.*", + from: "../node_modules/some-sass-language-server/dist/**/*.js", to: "[name][ext]", }, ], }), - ); + // Only register the plugin when RSDOCTOR is true, as the plugin will increase the build time. + process.env.RSDOCTOR && new RsdoctorRspackPlugin(), + ].filter(Boolean), +}; +module.exports = (env, argv) => { if (argv.mode === "development") { config.devtool = "source-map"; } diff --git a/vscode-extension/rspack.node.config.js b/vscode-extension/rspack.node.config.js index d4caeae9..f2cf442d 100644 --- a/vscode-extension/rspack.node.config.js +++ b/vscode-extension/rspack.node.config.js @@ -2,6 +2,7 @@ const path = require("path"); const rspack = require("@rspack/core"); +const { RsdoctorRspackPlugin } = require("@rsdoctor/rspack-plugin"); /** @type {import('@rspack/core').Configuration} **/ const config = { @@ -21,8 +22,21 @@ const config = { }, resolve: { extensions: [".ts", ".js"], + conditionNames: ["import", "require", "default"], + mainFields: ["module", "main"], }, - plugins: [], + plugins: [ + new rspack.CopyRspackPlugin({ + patterns: [ + { + from: "../node_modules/some-sass-language-server/dist/**/*.js", + to: "[name][ext]", + }, + ], + }), + // Only register the plugin when RSDOCTOR is true, as the plugin will increase the build time. + process.env.RSDOCTOR && new RsdoctorRspackPlugin(), + ].filter(Boolean), devtool: false, module: { rules: [ @@ -44,17 +58,6 @@ const config = { }; module.exports = (env, argv) => { - config.plugins?.push( - new rspack.CopyRspackPlugin({ - patterns: [ - { - from: "../node_modules/some-sass-language-server/dist/node-server.*", - to: "[name][ext]", - }, - ], - }), - ); - if (argv.mode === "development") { config.devtool = "source-map"; } diff --git a/vscode-extension/rspack.test-web.config.js b/vscode-extension/rspack.test-web.config.js index 4ceb7dc2..7f9ffcd4 100644 --- a/vscode-extension/rspack.test-web.config.js +++ b/vscode-extension/rspack.test-web.config.js @@ -39,6 +39,9 @@ const browserTestsConfig = { }, ], }, + performance: { + hints: false, + }, plugins: [ new rspack.ProvidePlugin({ process: "process/browser", diff --git a/vscode-extension/src/browser-client.ts b/vscode-extension/src/browser-client.ts index 141c57d0..e3a68b19 100644 --- a/vscode-extension/src/browser-client.ts +++ b/vscode-extension/src/browser-client.ts @@ -145,10 +145,7 @@ function createWorkerLanguageClient( context: ExtensionContext, clientOptions: LanguageClientOptions, ) { - const serverMain = Uri.joinPath( - context.extensionUri, - "dist/browser-server.js", - ); + const serverMain = Uri.joinPath(context.extensionUri, "dist/browser-main.js"); const worker = new Worker(serverMain.toString(/* skipEncoding */ true)); return new LanguageClient( diff --git a/vscode-extension/src/node-client.ts b/vscode-extension/src/node-client.ts index f5e02a08..7974d940 100644 --- a/vscode-extension/src/node-client.ts +++ b/vscode-extension/src/node-client.ts @@ -67,7 +67,7 @@ function getOuterMostWorkspaceFolder(folder: WorkspaceFolder): WorkspaceFolder { } export async function activate(context: ExtensionContext): Promise { - const serverModule = context.asAbsolutePath(`./dist/node-server.js`); + const serverModule = context.asAbsolutePath(`./dist/node-main.js`); async function didOpenTextDocument(document: TextDocument): Promise { if (