diff --git a/.azure-pipelines/publish-nightly.yml b/.azure-pipelines/publish-nightly.yml index 0716118d..17c903b0 100644 --- a/.azure-pipelines/publish-nightly.yml +++ b/.azure-pipelines/publish-nightly.yml @@ -42,7 +42,7 @@ extends: publishRequiresApproval: false - name: monaco-editor - workingDirectory: $(Build.SourcesDirectory)/release + workingDirectory: $(Build.SourcesDirectory)/out/monaco-editor testPlatforms: [] buildSteps: - script: npm ci diff --git a/.azure-pipelines/publish-stable.yml b/.azure-pipelines/publish-stable.yml index 718d6c5f..39b00325 100644 --- a/.azure-pipelines/publish-stable.yml +++ b/.azure-pipelines/publish-stable.yml @@ -44,7 +44,7 @@ extends: publishRequiresApproval: false - name: monaco-editor - workingDirectory: $(Build.SourcesDirectory)/release + workingDirectory: $(Build.SourcesDirectory)/out/monaco-editor testPlatforms: [] buildSteps: - script: npm ci diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a195a9c6..cfbe227d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: run: npm run prettier-check - name: Build - run: npm run release + run: npm run build-monaco-editor - name: Run unit tests run: npm test diff --git a/.github/workflows/website.yml b/.github/workflows/website.yml index ea94e488..7508da49 100644 --- a/.github/workflows/website.yml +++ b/.github/workflows/website.yml @@ -31,7 +31,7 @@ jobs: run: npm ci - name: Build - run: npm run release + run: npm run build-monaco-editor - name: Install website node modules working-directory: website diff --git a/.gitignore b/.gitignore index ab9f8f5a..678fdef0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,8 @@ **/node_modules/ -**/out/ -**/release/ **/dependencies/ /test/manual/generated/** /test/smoke/vite/dist/** /test/smoke/parcel/dist/** /test/smoke/parcel/.cache/** **/dist/ +**/out/ diff --git a/.prettierignore b/.prettierignore index b4b4870d..19e9315c 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,6 +1,6 @@ **/node_modules/ +**/dist/ **/out/ -**/release/ /samples/browser-esm-parcel/.parcel-cache/ /samples/browser-esm-parcel/dist/ /samples/browser-esm-vite-react/dist/**/*.js diff --git a/.vscode/launch.json b/.vscode/launch.json index 87ddf472..6cab7f01 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,7 +8,7 @@ "name": "Monaco Editor Playground", "type": "chrome", "request": "launch", - "url": "https://microsoft.github.io/monaco-editor/playground.html?sourceLanguages=http%3A%2F%2Flocalhost%3A5002%2Fout%2Famd", + "url": "https://microsoft.github.io/monaco-editor/playground.html?sourceLanguages=http%3A%2F%2Flocalhost%3A5002%2Fdist%2Flanguages%2Famd-tsc", "preLaunchTask": "Launch Http Server", "presentation": { "group": "monaco", @@ -22,7 +22,7 @@ "name": "Monaco Editor Playground (Load From VS Code Http Server)", "type": "chrome", "request": "launch", - "url": "https://microsoft.github.io/monaco-editor/playground.html?sourceLanguages=http%3A%2F%2Flocalhost%3A5002%2Fout%2Famd&source=http%3A%2F%2Flocalhost%3A5001%2Fout%2Fvs", + "url": "https://microsoft.github.io/monaco-editor/playground.html?sourceLanguages=http%3A%2F%2Flocalhost%3A5002%2Fdist%2Flanguages%2Famd-tsc&source=http%3A%2F%2Flocalhost%3A5001%2Fout%2Fvs", "preLaunchTask": "Launch Http Server", "presentation": { "group": "monaco", @@ -38,24 +38,6 @@ "args": ["-r", "test/unit/all.js"], "outFiles": ["${workspaceFolder}/**/*.js"] }, - { - "type": "node", - "request": "launch", - "name": "release", - "skipFiles": ["/**"], - "program": "${workspaceFolder}/build/release.js", - "args": [], - "cwd": "${workspaceFolder}" - }, - { - "type": "node", - "request": "launch", - "name": "website", - "skipFiles": ["/**"], - "program": "${workspaceFolder}/build/website.js", - "args": [], - "cwd": "${workspaceFolder}" - }, { "type": "node", "request": "launch", diff --git a/.vscode/settings.json b/.vscode/settings.json index 6794ef5b..176dc5ad 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,7 +6,7 @@ "files.trimTrailingWhitespace": true, "search.exclude": { "**/node_modules": true, - "**/release": true, + "**/dist": true, "**/out": true }, "typescript.tsdk": "./node_modules/typescript/lib", diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 10c7f30b..3cfa8ec8 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -27,77 +27,30 @@ import './{myLang}/{myLang}.contribution'; ## Debugging / Developing The Core Editor +TODO + ## Debugging / Developing Language Support +TODO + ## Running the editor from source -You need to have all the build setup of VS Code to be able to build the Monaco Editor. - -- Install all the [prerequisites](https://github.com/microsoft/vscode/wiki/How-to-Contribute#prerequisites) - -```bash -# clone vscode-loc repository for localized string resources -/src> git clone https://github.com/microsoft/vscode-loc -# clone VS Code repository -/src> git clone https://github.com/microsoft/vscode -/src> cd vscode -# install npm deps for vscode -/src/vscode> yarn -# start the compiler in the background -/src/vscode> yarn watch -``` - -- For the monaco editor test pages: - -```bash -# clone monaco-editor (note the folders must be siblings!) -/src> git clone https://github.com/microsoft/monaco-editor - -# install npm deps for monaco-editor -/src/monaco-editor> npm install . - -# compile and bundle all plugins -/src/monaco-editor> npm run release - -# start a local http server in the background -/src/monaco-editor> npm run simpleserver -``` - -Open [http://localhost:8080/monaco-editor/test/manual/?editor=src](http://localhost:8080/monaco-editor/test/manual/?editor=src) to run. +TODO ## Running the editor tests ```bash -# create a local release -/src/monaco-editor> npm run release +> npm run build-monaco-editor +> npm run test +> npm run compile --prefix webpack-plugin -# run unit tests -/src/monaco-editor> npm run test - -# compile the webpack plugin -/src/monaco-editor> npm run compile --prefix webpack-plugin - -# package using the webpack plugin -/src/monaco-editor> npm run package-for-smoketest-webpack - -# package using esbuild -/src/monaco-editor> npm run package-for-smoketest-esbuild - -# package using vite -/src/monaco-editor> npm run package-for-smoketest-vite - -# package using parcel -/src/monaco-editor> npm run package-for-smoketest-parcel --prefix test/smoke/parcel - -# run the smoketest -/src/monaco-editor> npm run smoketest-debug +> npm run package-for-smoketest-webpack +> npm run package-for-smoketest-esbuild +> npm run package-for-smoketest-vite +> npm run package-for-smoketest-parcel --prefix test/smoke/parcel +> npm run smoketest-debug ``` -> Tip: All folders must be cloned as siblings. - -> Tip: When running the test pages, use the control panel in the top right corner to switch between running from source, running from npm or running from the local release: -> ![image](https://cloud.githubusercontent.com/assets/5047891/19599080/eb0d7622-979e-11e6-96ce-dde98cd95dc1.png) - ## Running the website locally TOD diff --git a/build/build.ts b/build/build-languages.ts similarity index 87% rename from build/build.ts rename to build/build-languages.ts index e0bc5453..8a6e7393 100644 --- a/build/build.ts +++ b/build/build-languages.ts @@ -4,33 +4,33 @@ *--------------------------------------------------------------------------------------------*/ import glob from 'glob'; -import { tsc, dts, buildESM, buildAMD } from './utils'; +import { runTsc, massageAndCopyDts, buildESM, buildAMD } from './utils'; import { copyFile, removeDir } from './fs'; -removeDir(`out`); +removeDir(`out/languages`); -tsc(`src/tsconfig.json`); +runTsc(`src/tsconfig.json`); //#region Type Defintion -dts( - `out/amd/language/css/monaco.contribution.d.ts`, - `out/release/css.d.ts`, +massageAndCopyDts( + `out/languages/amd-tsc/language/css/monaco.contribution.d.ts`, + `out/languages/bundled/css.d.ts`, 'monaco.languages.css' ); -dts( - `out/amd/language/html/monaco.contribution.d.ts`, - `out/release/html.d.ts`, +massageAndCopyDts( + `out/languages/amd-tsc/language/html/monaco.contribution.d.ts`, + `out/languages/bundled/html.d.ts`, 'monaco.languages.html' ); -dts( - `out/amd/language/json/monaco.contribution.d.ts`, - `out/release/json.d.ts`, +massageAndCopyDts( + `out/languages/amd-tsc/language/json/monaco.contribution.d.ts`, + `out/languages/bundled/json.d.ts`, 'monaco.languages.json' ); -dts( - `out/amd/language/typescript/monaco.contribution.d.ts`, - `out/release/typescript.d.ts`, +massageAndCopyDts( + `out/languages/amd-tsc/language/typescript/monaco.contribution.d.ts`, + `out/languages/bundled/typescript.d.ts`, 'monaco.languages.typescript' ); @@ -133,7 +133,7 @@ buildAMD({ copyFile( `src/language/typescript/lib/typescriptServices-amd.js`, - `out/amd/language/typescript/lib/typescriptServices.js` + `out/languages/amd-tsc/language/typescript/lib/typescriptServices.js` ); buildESM({ diff --git a/build/release.ts b/build/build-monaco-editor.ts similarity index 91% rename from build/release.ts rename to build/build-monaco-editor.ts index 303faf40..1a2d3ba0 100644 --- a/build/release.ts +++ b/build/build-monaco-editor.ts @@ -10,7 +10,7 @@ import { removeDir } from '../build/fs'; import ts = require('typescript'); import { generateMetadata } from './releaseMetadata'; -removeDir(`release`); +removeDir(`out/monaco-editor`); // dev folder AMD_releaseOne('dev'); @@ -39,7 +39,7 @@ generateMetadata(); delete json.scripts['postinstall']; packageJSON.contents = Buffer.from(JSON.stringify(json, null, ' ')); - writeFiles([packageJSON], `release`); + writeFiles([packageJSON], `out/monaco-editor`); })(); (() => { @@ -59,7 +59,7 @@ generateMetadata(); }) ); - writeFiles(otherFiles, `release`); + writeFiles(otherFiles, `out/monaco-editor`); })(); /** @@ -70,13 +70,13 @@ function AMD_releaseOne(type: 'dev' | 'min') { base: `node_modules/monaco-editor-core/${type}` }); AMD_addPluginContribs(type, coreFiles); - writeFiles(coreFiles, `release/${type}`); + writeFiles(coreFiles, `out/monaco-editor/${type}`); - const pluginFiles = readFiles(`out/release/${type}/**/*`, { - base: `out/release/${type}`, + const pluginFiles = readFiles(`out/languages/bundled/amd-${type}/**/*`, { + base: `out/languages/bundled/amd-${type}`, ignore: ['**/monaco.contribution.js'] }); - writeFiles(pluginFiles, `release/${type}`); + writeFiles(pluginFiles, `out/monaco-editor/${type}`); } /** @@ -96,8 +96,8 @@ function AMD_addPluginContribs(type: 'dev' | 'min', files: IFile[]) { // Rename the AMD module 'vs/editor/editor.main' to 'vs/editor/edcore.main' contents = contents.replace(/"vs\/editor\/editor\.main\"/, '"vs/editor/edcore.main"'); - const pluginFiles = readFiles(`out/release/${type}/**/monaco.contribution.js`, { - base: `out/release/${type}` + const pluginFiles = readFiles(`out/languages/bundled/amd-${type}/**/monaco.contribution.js`, { + base: `out/languages/bundled/amd-${type}` }); const extraContent = pluginFiles.map((file) => { @@ -141,7 +141,7 @@ function ESM_release() { }); ESM_addImportSuffix(coreFiles); ESM_addPluginContribs(coreFiles); - writeFiles(coreFiles, `release/esm`); + writeFiles(coreFiles, `out/monaco-editor/esm`); ESM_releasePlugins(); } @@ -152,7 +152,7 @@ function ESM_release() { * Rewrites imports for 'monaco-editor-core/**' */ function ESM_releasePlugins() { - const files = readFiles(`out/release/esm/**/*`, { base: 'out/release/esm/' }); + const files = readFiles(`out/languages/bundled/esm/**/*`, { base: 'out/languages/bundled/esm/' }); for (const file of files) { if (!/(\.js$)|(\.ts$)/.test(file.path)) { @@ -210,7 +210,7 @@ function ESM_releasePlugins() { } ESM_addImportSuffix(files); - writeFiles(files, `release/esm`); + writeFiles(files, `out/monaco-editor/esm`); } /** @@ -256,8 +256,8 @@ function ESM_addPluginContribs(files: IFile[]) { const mainFileDestPath = 'vs/editor/editor.main.js'; - const mainFileImports = readFiles(`out/release/esm/**/monaco.contribution.js`, { - base: `out/release/esm` + const mainFileImports = readFiles(`out/languages/bundled/esm/**/monaco.contribution.js`, { + base: `out/languages/bundled/esm` }).map((file) => { let relativePath = path .relative(path.dirname(mainFileDestPath), file.path) @@ -292,8 +292,8 @@ function releaseDTS() { let contents = monacodts.contents.toString(); - const extraContent = readFiles('out/release/*.d.ts', { - base: 'out/release/' + const extraContent = readFiles('out/languages/bundled/*.d.ts', { + base: 'out/languages/bundled/' }).map((file) => { return file.contents.toString().replace(/\/\/\/ { return new Promise((resolve, reject) => { glob( - './release/esm/vs/basic-languages/*/*.contribution.js', + './out/monaco-editor/esm/vs/basic-languages/*/*.contribution.js', { cwd: path.dirname(__dirname) }, (err, files) => { if (err) { @@ -36,7 +36,7 @@ function getBasicLanguages(): Promise<{ label: string; entry: string }[]> { resolve( files.map((file) => { - const entry = file.substring('./release/esm/'.length).replace(/\.js$/, ''); + const entry = file.substring('./out/monaco-editor/esm/'.length).replace(/\.js$/, ''); const label = path.basename(file).replace(/\.contribution\.js$/, ''); return { label: label, @@ -52,7 +52,7 @@ function getBasicLanguages(): Promise<{ label: string; entry: string }[]> { function readAdvancedLanguages(): Promise { return new Promise((resolve, reject) => { glob( - './release/esm/vs/language/*/monaco.contribution.js', + './out/monaco-editor/esm/vs/language/*/monaco.contribution.js', { cwd: path.dirname(__dirname) }, (err, files) => { if (err) { @@ -62,7 +62,7 @@ function readAdvancedLanguages(): Promise { resolve( files - .map((file) => file.substring('./release/esm/vs/language/'.length)) + .map((file) => file.substring('./out/monaco-editor/esm/vs/language/'.length)) .map((file) => file.substring(0, file.length - '/monaco.contribution.js'.length)) ); } @@ -95,7 +95,7 @@ function getAdvancedLanguages(): Promise< }); function checkFileExists(moduleName) { - const filePath = path.join(REPO_ROOT, 'release/esm', `${moduleName}.js`); + const filePath = path.join(REPO_ROOT, 'out/monaco-editor/esm', `${moduleName}.js`); if (!fs.existsSync(filePath)) { console.error(`Could not find ${filePath}.`); process.exit(1); @@ -174,7 +174,7 @@ export type EditorFeature = ${features.map((el) => `'${el.label}'`).join(' | ')} export type NegatedEditorFeature = ${features.map((el) => `'!${el.label}'`).join(' | ')}; `; - const dtsDestination = path.join(REPO_ROOT, 'release/esm/metadata.d.ts'); + const dtsDestination = path.join(REPO_ROOT, 'out/monaco-editor/esm/metadata.d.ts'); ensureDir(path.dirname(dtsDestination)); fs.writeFileSync(dtsDestination, dtsContents.replace(/\r\n/g, '\n')); @@ -182,7 +182,7 @@ export type NegatedEditorFeature = ${features.map((el) => `'!${el.label}'`).join exports.features = ${JSON.stringify(features, null, ' ')}; exports.languages = ${JSON.stringify(languages, null, ' ')}; `; - const jsDestination = path.join(REPO_ROOT, 'release/esm/metadata.js'); + const jsDestination = path.join(REPO_ROOT, 'out/monaco-editor/esm/metadata.js'); ensureDir(path.dirname(jsDestination)); fs.writeFileSync(jsDestination, jsContents.replace(/\r\n/g, '\n')); } @@ -213,8 +213,12 @@ function getFeatures(): { label: string; entry: string | string[] }[] { let features: string[] = []; const files = - fs.readFileSync(path.join(REPO_ROOT, 'release/esm/vs/editor/edcore.main.js')).toString() + - fs.readFileSync(path.join(REPO_ROOT, 'release/esm/vs/editor/editor.all.js')).toString(); + fs + .readFileSync(path.join(REPO_ROOT, 'out/monaco-editor/esm/vs/editor/edcore.main.js')) + .toString() + + fs + .readFileSync(path.join(REPO_ROOT, 'out/monaco-editor/esm/vs/editor/editor.all.js')) + .toString(); files.split(/\r\n|\n/).forEach((line) => { const m = line.match(/import '([^']+)'/); if (m) { diff --git a/build/utils.ts b/build/utils.ts index 472ae44a..06f056ef 100644 --- a/build/utils.ts +++ b/build/utils.ts @@ -16,7 +16,7 @@ export const REPO_ROOT = path.join(__dirname, '../'); /** * Launch the typescript compiler synchronously over a project. */ -export function tsc(_projectPath: string) { +export function runTsc(_projectPath: string) { const projectPath = path.join(REPO_ROOT, _projectPath); console.log(`Launching compiler at ${_projectPath}...`); const res = cp.spawnSync( @@ -47,12 +47,12 @@ export function prettier(_filePath: string) { /** * Transform an external .d.ts file to an internal .d.ts file */ -export function dts(_source: string, _destination: string, namespace: string) { - const source = path.join(REPO_ROOT, _source); - const destination = path.join(REPO_ROOT, _destination); +export function massageAndCopyDts(source: string, destination: string, namespace: string) { + const absoluteSource = path.join(REPO_ROOT, source); + const absoluteDestination = path.join(REPO_ROOT, destination); const lines = fs - .readFileSync(source) + .readFileSync(absoluteSource) .toString() .split(/\r\n|\r|\n/); @@ -81,10 +81,10 @@ export function dts(_source: string, _destination: string, namespace: string) { result.push(`}`); result.push(``); - ensureDir(path.dirname(destination)); - fs.writeFileSync(destination, result.join('\n')); + ensureDir(path.dirname(absoluteDestination)); + fs.writeFileSync(absoluteDestination, result.join('\n')); - prettier(_destination); + prettier(destination); } export function build(options: import('esbuild').BuildOptions) { @@ -113,7 +113,7 @@ export function buildESM(options: { base: string; entryPoints: string[]; externa }, external: options.external, outbase: `src/${options.base}`, - outdir: `out/release/esm/vs/${options.base}/`, + outdir: `out/languages/bundled/esm/vs/${options.base}/`, plugins: [ alias({ 'vscode-nls': path.join(__dirname, 'fillers/vscode-nls.ts') @@ -156,7 +156,7 @@ function buildOneAMD( js: 'return moduleExports;\n});' }, outbase: `src/${options.base}`, - outdir: `out/release/${type}/vs/${options.base}/`, + outdir: `out/languages/bundled/amd-${type}/vs/${options.base}/`, plugins: [ alias({ 'vscode-nls': path.join(__dirname, '../build/fillers/vscode-nls.ts'), diff --git a/package.json b/package.json index ea44e01b..fd984ba2 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,6 @@ "prettier-check": "prettier --check .", "prettier": "prettier --write .", "pretty-quick": "pretty-quick --staged", - "release": "ts-node ./build/build && ts-node ./build/release", "simpleserver": "ts-node ./build/simpleserver", "package-for-smoketest-webpack": "ts-node ./test/smoke/package-webpack", "package-for-smoketest-webpack-cross-origin": "ts-node ./test/smoke/package-webpack --cross-origin", @@ -26,8 +25,10 @@ "test": "mocha test/unit/all.js && ts-node ./build/check-samples", "deps-all-remove": "ts-node ./build/npm/removeAll", "deps-all-install": "ts-node ./build/npm/installAll", + "update-actions": "pin-github-action ./.github/workflows/website.yml", "watch": "tsc -w -p ./src", - "update-actions": "pin-github-action ./.github/workflows/website.yml" + "build": "ts-node ./build/build-languages", + "build-monaco-editor": "npm run build && ts-node ./build/build-monaco-editor" }, "typings": "./esm/vs/editor/editor.api.d.ts", "module": "./esm/vs/editor/editor.main.js", diff --git a/scripts/ci/monaco-editor-prepare.ts b/scripts/ci/monaco-editor-prepare.ts index 2a46a5e1..2791ec84 100644 --- a/scripts/ci/monaco-editor-prepare.ts +++ b/scripts/ci/monaco-editor-prepare.ts @@ -30,7 +30,7 @@ async function prepareMonacoEditorReleaseStableOrNightly() { await prepareMonacoEditorRelease(version); - // npm package is now in ./release, ready to be published + // npm package is now in ./out/monaco-editor, ready to be published } async function prepareMonacoEditorRelease(monacoEditorCoreVersion: string) { diff --git a/scripts/ci/monaco-editor.sh b/scripts/ci/monaco-editor.sh index 4da4edbc..344c5c08 100755 --- a/scripts/ci/monaco-editor.sh +++ b/scripts/ci/monaco-editor.sh @@ -6,7 +6,7 @@ sudo npm run playwright-install-deps # Check prettier npm run prettier-check # Build -npm run release +npm run build-monaco-editor # Run unit tests npm test @@ -25,4 +25,4 @@ npm run package-for-smoketest-parcel --prefix test/smoke/parcel # Run smoke test npm run smoketest -# npm package is now ready to be published in ./release +# npm package is now ready to be published in ./out/monaco-editor diff --git a/src/tsconfig.json b/src/tsconfig.json index 99dce391..ead7b014 100644 --- a/src/tsconfig.json +++ b/src/tsconfig.json @@ -4,7 +4,7 @@ "lib": ["dom", "es5", "es2015.collection", "es2015.promise", "es2015.iterable"], "module": "amd", "moduleResolution": "node", - "outDir": "../out/amd", + "outDir": "../out/languages/amd-tsc", "strict": true, "target": "es5", "sourceMap": true diff --git a/test/smoke/amd/index.html b/test/smoke/amd/index.html index 2453a960..a50ce51d 100644 --- a/test/smoke/amd/index.html +++ b/test/smoke/amd/index.html @@ -5,11 +5,11 @@
- +