diff --git a/samples/browser-esm-webpack-monaco-plugin/index.js b/samples/browser-esm-webpack-monaco-plugin/index.js index 712ccd1f..27c82f59 100644 --- a/samples/browser-esm-webpack-monaco-plugin/index.js +++ b/samples/browser-esm-webpack-monaco-plugin/index.js @@ -1,4 +1,4 @@ -import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; +import * as monaco from 'monaco-editor'; (function () { // create div to avoid needing a HtmlWebpackPlugin template diff --git a/test/smoke/webpack/index.js b/test/smoke/webpack/index.js index f4e62ee8..edcd18b6 100644 --- a/test/smoke/webpack/index.js +++ b/test/smoke/webpack/index.js @@ -1,4 +1,4 @@ -import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; +import * as monaco from 'monaco-editor'; // expose the monaco API as a global for tests window.monacoAPI = monaco; diff --git a/webpack-plugin/README.md b/webpack-plugin/README.md index e97f5c9e..1301252e 100644 --- a/webpack-plugin/README.md +++ b/webpack-plugin/README.md @@ -51,8 +51,6 @@ If using Webpack 4 or lower, it is necessary to use the file-loader instead of A ```js import * as monaco from 'monaco-editor'; -// or import * as monaco from 'monaco-editor/esm/vs/editor/editor.api'; -// if shipping only a subset of the features & languages is desired monaco.editor.create(document.getElementById('container'), { value: 'console.log("Hello, world")', diff --git a/webpack-plugin/src/index.ts b/webpack-plugin/src/index.ts index ea8ca293..46d2f4fb 100644 --- a/webpack-plugin/src/index.ts +++ b/webpack-plugin/src/index.ts @@ -320,7 +320,7 @@ function createLoaderRules( }; return [ { - test: /esm[/\\]vs[/\\]editor[/\\]editor.(api|main).js/, + test: /esm[/\\]vs[/\\]editor[/\\]editor.main.js/, use: [ { loader: INCLUDE_LOADER_PATH, diff --git a/webpack-plugin/src/loaders/include.ts b/webpack-plugin/src/loaders/include.ts index 4bebcce9..1b4a0e95 100644 --- a/webpack-plugin/src/loaders/include.ts +++ b/webpack-plugin/src/loaders/include.ts @@ -26,14 +26,16 @@ export const pitch: PitchLoaderDefinitionFunction = function pit return loaderUtils.stringifyRequest(this, request); }; + // editor.main.js contains all features and languages, replace it with requested features, languages and editor.api.js + const apiRequest = remainingRequest.replace(/editor\.main\.js$/, 'editor.api.js'); return [ ...(globals ? Object.keys(globals).map((key) => `self[${JSON.stringify(key)}] = ${globals[key]};`) : []), ...pre.map((include: any) => `import ${stringifyRequest(include)};`), ` -import * as monaco from ${stringifyRequest(`!!${remainingRequest}`)}; -export * from ${stringifyRequest(`!!${remainingRequest}`)}; +import * as monaco from ${stringifyRequest(`!!${apiRequest}`)}; +export * from ${stringifyRequest(`!!${apiRequest}`)}; export default monaco; `, ...post.map((include: any) => `import ${stringifyRequest(include)};`)