From aa5bb2cfa7f43f8d18b8364f2892d50c627821de Mon Sep 17 00:00:00 2001 From: Alexandru Dima Date: Fri, 12 Nov 2021 14:14:05 +0100 Subject: [PATCH] Avoid going through separate `package.json` files --- CONTRIBUTING.md | 6 +----- build/utils.js | 15 +++++++++------ monaco-css/build.js | 4 ++++ monaco-css/package.json | 3 +-- monaco-html/build.js | 4 ++++ monaco-html/package.json | 3 +-- monaco-json/build.js | 4 ++++ monaco-json/package.json | 3 +-- monaco-languages/build.js | 3 +++ monaco-languages/package.json | 3 +-- monaco-typescript/build.js | 9 ++++----- monaco-typescript/package.json | 1 - package.json | 10 +++++----- 13 files changed, 38 insertions(+), 30 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 996c5e77..47da1083 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -55,11 +55,7 @@ You need to have all the build setup of VS Code to be able to build the Monaco E /src/monaco-editor> npm install . # compile all plugins -/src/monaco-editor> npm run prepublishOnly --prefix monaco-css -/src/monaco-editor> npm run prepublishOnly --prefix monaco-languages -/src/monaco-editor> npm run prepublishOnly --prefix monaco-typescript -/src/monaco-editor> npm run prepublishOnly --prefix monaco-json -/src/monaco-editor> npm run prepublishOnly --prefix monaco-html +/src/monaco-editor> npm run release # start a local http server in the background /src/monaco-editor> npm run simpleserver diff --git a/build/utils.js b/build/utils.js index 4e31de6f..9a94cff4 100644 --- a/build/utils.js +++ b/build/utils.js @@ -178,13 +178,14 @@ exports.build = build; /** * @param {{ + * base: string; * entryPoints: string[]; * external: string[]; * }} options */ function buildESM(options) { build({ - entryPoints: options.entryPoints, + entryPoints: options.entryPoints.map(e => (`${options.base}/${e}`)), bundle: true, target: 'esnext', format: 'esm', @@ -192,8 +193,8 @@ function buildESM(options) { AMD: 'false' }, external: options.external, - outbase: 'src', - outdir: 'release/esm/', + outbase: `${options.base}/src`, + outdir: `${options.base}/release/esm/`, plugins: [ alias({ 'vscode-nls': path.join(__dirname, 'fillers/vscode-nls.ts') @@ -206,6 +207,7 @@ exports.buildESM = buildESM; /** * @param {'dev'|'min'} type * @param {{ + * base: string; * entryPoint: string; * banner: string; * }} options @@ -213,7 +215,7 @@ exports.buildESM = buildESM; function buildOneAMD(type, options) { /** @type {import('esbuild').BuildOptions} */ const opts = { - entryPoints: [options.entryPoint], + entryPoints: [`${options.base}/${options.entryPoint}`], bundle: true, target: 'esnext', format: 'iife', @@ -227,8 +229,8 @@ function buildOneAMD(type, options) { footer: { js: 'return moduleExports;\n});' }, - outbase: 'src', - outdir: `release/${type}/`, + outbase: `${options.base}/src`, + outdir: `${options.base}/release/${type}/`, plugins: [ alias({ 'vscode-nls': path.join(__dirname, '../build/fillers/vscode-nls.ts'), @@ -244,6 +246,7 @@ function buildOneAMD(type, options) { /** * @param {{ + * base: string; * entryPoint: string; * banner: string; * }} options diff --git a/monaco-css/build.js b/monaco-css/build.js index 7658d754..b45b93d5 100644 --- a/monaco-css/build.js +++ b/monaco-css/build.js @@ -19,18 +19,22 @@ dts( ); buildESM({ + base: 'monaco-css', entryPoints: ['src/monaco.contribution.ts', 'src/cssMode.ts', 'src/css.worker.ts'], external: ['monaco-editor-core', '*/cssMode'] }); buildAMD({ + base: 'monaco-css', entryPoint: 'src/monaco.contribution.ts', banner: 'define("vs/language/css/monaco.contribution",["vs/editor/editor.api"],()=>{' }); buildAMD({ + base: 'monaco-css', entryPoint: 'src/cssMode.ts', banner: 'define("vs/language/css/cssMode",["vs/editor/editor.api"],()=>{' }); buildAMD({ + base: 'monaco-css', entryPoint: 'src/cssWorker.ts', banner: 'define("vs/language/css/cssWorker",[],()=>{' }); diff --git a/monaco-css/package.json b/monaco-css/package.json index d1f6cc74..1abe9e70 100644 --- a/monaco-css/package.json +++ b/monaco-css/package.json @@ -1,6 +1,5 @@ { "scripts": { - "watch": "../node_modules/.bin/tsc -p ./src --watch", - "prepublishOnly": "node ./build" + "watch": "../node_modules/.bin/tsc -p ./src --watch" } } diff --git a/monaco-html/build.js b/monaco-html/build.js index 25692bd3..508d4b4d 100644 --- a/monaco-html/build.js +++ b/monaco-html/build.js @@ -19,18 +19,22 @@ dts( ); buildESM({ + base: 'monaco-html', entryPoints: ['src/monaco.contribution.ts', 'src/htmlMode.ts', 'src/html.worker.ts'], external: ['monaco-editor-core', '*/htmlMode'] }); buildAMD({ + base: 'monaco-html', entryPoint: 'src/monaco.contribution.ts', banner: 'define("vs/language/html/monaco.contribution",["vs/editor/editor.api"],()=>{' }); buildAMD({ + base: 'monaco-html', entryPoint: 'src/htmlMode.ts', banner: 'define("vs/language/html/htmlMode",["vs/editor/editor.api"],()=>{' }); buildAMD({ + base: 'monaco-html', entryPoint: 'src/htmlWorker.ts', banner: 'define("vs/language/html/htmlWorker",[],()=>{' }); diff --git a/monaco-html/package.json b/monaco-html/package.json index d1f6cc74..1abe9e70 100644 --- a/monaco-html/package.json +++ b/monaco-html/package.json @@ -1,6 +1,5 @@ { "scripts": { - "watch": "../node_modules/.bin/tsc -p ./src --watch", - "prepublishOnly": "node ./build" + "watch": "../node_modules/.bin/tsc -p ./src --watch" } } diff --git a/monaco-json/build.js b/monaco-json/build.js index f6f6efab..8731ad82 100644 --- a/monaco-json/build.js +++ b/monaco-json/build.js @@ -19,18 +19,22 @@ dts( ); buildESM({ + base: 'monaco-json', entryPoints: ['src/monaco.contribution.ts', 'src/jsonMode.ts', 'src/json.worker.ts'], external: ['monaco-editor-core', '*/jsonMode'] }); buildAMD({ + base: 'monaco-json', entryPoint: 'src/monaco.contribution.ts', banner: 'define("vs/language/json/monaco.contribution",["vs/editor/editor.api"],()=>{' }); buildAMD({ + base: 'monaco-json', entryPoint: 'src/jsonMode.ts', banner: 'define("vs/language/json/jsonMode",["vs/editor/editor.api"],()=>{' }); buildAMD({ + base: 'monaco-json', entryPoint: 'src/jsonWorker.ts', banner: 'define("vs/language/json/jsonWorker",[],()=>{' }); diff --git a/monaco-json/package.json b/monaco-json/package.json index d1f6cc74..1abe9e70 100644 --- a/monaco-json/package.json +++ b/monaco-json/package.json @@ -1,6 +1,5 @@ { "scripts": { - "watch": "../node_modules/.bin/tsc -p ./src --watch", - "prepublishOnly": "node ./build" + "watch": "../node_modules/.bin/tsc -p ./src --watch" } } diff --git a/monaco-languages/build.js b/monaco-languages/build.js index 0d8573ff..96dbc2a4 100644 --- a/monaco-languages/build.js +++ b/monaco-languages/build.js @@ -33,6 +33,7 @@ glob('src/*/*.contribution.ts', { cwd: __dirname }, function (err, files) { external.push(`*/${language}`); } buildESM({ + base: 'monaco-languages', entryPoints, external }); @@ -41,11 +42,13 @@ glob('src/*/*.contribution.ts', { cwd: __dirname }, function (err, files) { // AMD { buildAMD({ + base: 'monaco-languages', entryPoint: 'src/monaco.contribution.ts', banner: 'define("vs/basic-languages/monaco.contribution",["vs/editor/editor.api"],()=>{' }); for (const language of languages) { buildAMD({ + base: 'monaco-languages', entryPoint: `src/${language}/${language}.ts`, banner: `define("vs/basic-languages/${language}/${language}",[],()=>{` }); diff --git a/monaco-languages/package.json b/monaco-languages/package.json index c55b4b4d..9069711a 100644 --- a/monaco-languages/package.json +++ b/monaco-languages/package.json @@ -1,7 +1,6 @@ { "scripts": { "watch": "../node_modules/.bin/tsc -p ./src --watch", - "test": "node ./test/all.js", - "prepublishOnly": "node ./build" + "test": "node ./test/all.js" } } diff --git a/monaco-typescript/build.js b/monaco-typescript/build.js index 7d02b34f..f6572303 100644 --- a/monaco-typescript/build.js +++ b/monaco-typescript/build.js @@ -15,11 +15,6 @@ copyFile( `monaco-typescript/out/amd/lib/typescriptServices.js` ); -copyFile( - `monaco-typescript/src/lib/typescriptServices.js`, - `monaco-typescript/out/esm/lib/typescriptServices.js` -); - tsc(`monaco-typescript/src/tsconfig.json`); dts( @@ -29,18 +24,22 @@ dts( ); buildESM({ + base: 'monaco-typescript', entryPoints: ['src/monaco.contribution.ts', 'src/tsMode.ts', 'src/ts.worker.ts'], external: ['monaco-editor-core', '*/tsMode'] }); buildAMD({ + base: 'monaco-typescript', entryPoint: 'src/monaco.contribution.ts', banner: 'define("vs/language/typescript/monaco.contribution",["vs/editor/editor.api"],()=>{' }); buildAMD({ + base: 'monaco-typescript', entryPoint: 'src/tsMode.ts', banner: 'define("vs/language/typescript/tsMode",["vs/editor/editor.api"],()=>{' }); buildAMD({ + base: 'monaco-typescript', entryPoint: 'src/tsWorker.ts', banner: 'define("vs/language/typescript/tsWorker",[],()=>{' }); diff --git a/monaco-typescript/package.json b/monaco-typescript/package.json index 15bd4f17..b468673c 100644 --- a/monaco-typescript/package.json +++ b/monaco-typescript/package.json @@ -1,7 +1,6 @@ { "scripts": { "watch": "../node_modules/.bin/tsc -p ./src --watch", - "prepublishOnly": "node ./build", "import-typescript": "node ./scripts/importTypescript" } } diff --git a/package.json b/package.json index b59ed045..e8f8a698 100644 --- a/package.json +++ b/package.json @@ -7,11 +7,11 @@ "license": "MIT", "scripts": { "simpleserver": "gulp simpleserver", - "release-css": "npm run prepublishOnly --prefix monaco-css", - "release-html": "npm run prepublishOnly --prefix monaco-html", - "release-json": "npm run prepublishOnly --prefix monaco-json", - "release-languages": "npm run prepublishOnly --prefix monaco-languages", - "release-typescript": "npm run prepublishOnly --prefix monaco-typescript", + "release-css": "node ./monaco-css/build", + "release-html": "node ./monaco-html/build", + "release-json": "node ./monaco-json/build", + "release-languages": "node ./monaco-languages/build", + "release-typescript": "node ./monaco-typescript/build", "release": "npm run release-css && npm run release-html && npm run release-json && npm run release-languages && npm run release-typescript && gulp release", "website": "gulp build-website && npm run typedoc && gulp prepare-website-branch", "build-website": "gulp build-website && npm run typedoc",