mirror of
https://github.com/microsoft/monaco-editor.git
synced 2025-12-22 16:15:41 +01:00
Add webpack loader plugin
This commit is contained in:
parent
32f5433657
commit
7d6ae1b4f3
8 changed files with 1144 additions and 0 deletions
20
webpack/loaders/include.js
Normal file
20
webpack/loaders/include.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
const loaderUtils = require('loader-utils');
|
||||
|
||||
module.exports.pitch = function pitch(remainingRequest) {
|
||||
const { globals = undefined, pre = [], post = [] } = loaderUtils.getOptions(this) || {};
|
||||
|
||||
// HACK: NamedModulesPlugin overwrites existing modules when requesting the same module via
|
||||
// different loaders, so we need to circumvent this by appending a suffix to make the name unique
|
||||
// See https://github.com/webpack/webpack/issues/4613#issuecomment-325178346 for details
|
||||
this._module.userRequest = `include-loader!${this._module.userRequest}`;
|
||||
|
||||
return [
|
||||
...(globals
|
||||
? Object.keys(globals).map((key) => `self[${JSON.stringify(key)}] = ${globals[key]};`)
|
||||
: []
|
||||
),
|
||||
...pre.map((include) => `require(${loaderUtils.stringifyRequest(this, include)});`),
|
||||
`module.exports = require(${loaderUtils.stringifyRequest(this, `!!${remainingRequest}`)});`,
|
||||
...post.map((include) => `require(${loaderUtils.stringifyRequest(this, include)});`),
|
||||
].join('\n');
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue