support arrow function in umd
This commit is contained in:
parent
86a8bd9618
commit
806ee08c3f
|
@ -310,9 +310,11 @@ class UmdLibraryPlugin extends AbstractLibraryPlugin {
|
|||
: " var a = factory();\n") +
|
||||
" for(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n" +
|
||||
" }\n") +
|
||||
`})(${
|
||||
runtimeTemplate.outputOptions.globalObject
|
||||
}, function(${externalsArguments(externals)}) {\nreturn `,
|
||||
`})(${runtimeTemplate.outputOptions.globalObject}, ${
|
||||
runtimeTemplate.supportsArrowFunction()
|
||||
? `(${externalsArguments(externals)}) =>`
|
||||
: `function(${externalsArguments(externals)})`
|
||||
} {\nreturn `,
|
||||
"webpack/universalModuleDefinition"
|
||||
),
|
||||
source,
|
||||
|
|
|
@ -619,7 +619,12 @@ const describeCases = config => {
|
|||
const fn = runInNewContext
|
||||
? vm.runInNewContext(code, globalContext, p)
|
||||
: vm.runInThisContext(code, p);
|
||||
fn.call(m.exports, ...argValues);
|
||||
fn.call(
|
||||
testConfig.nonEsmThis
|
||||
? testConfig.nonEsmThis(module)
|
||||
: m.exports,
|
||||
...argValues
|
||||
);
|
||||
document.currentScript = oldCurrentScript;
|
||||
return m.exports;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
it("should compile and run", () => {
|
||||
expect(hello()).toBe("hello");
|
||||
});
|
||||
|
||||
export function hello() { return "hello"; }
|
|
@ -0,0 +1,9 @@
|
|||
const CONTEXT = {};
|
||||
module.exports = {
|
||||
nonEsmThis(module) {
|
||||
return CONTEXT;
|
||||
},
|
||||
findBundle() {
|
||||
return ["./runtime.js", "./main.js"];
|
||||
}
|
||||
};
|
|
@ -0,0 +1,19 @@
|
|||
/** @type {import("../../../../").Configuration} */
|
||||
module.exports = {
|
||||
mode: "production",
|
||||
entry: {
|
||||
main: "./index.js"
|
||||
},
|
||||
output: {
|
||||
filename: "[name].js",
|
||||
library: "MyLibrary",
|
||||
libraryTarget: "umd",
|
||||
chunkLoading: "jsonp",
|
||||
chunkFormat: "array-push",
|
||||
globalObject: "this"
|
||||
},
|
||||
optimization: {
|
||||
minimize: false,
|
||||
runtimeChunk: "single"
|
||||
}
|
||||
};
|
Loading…
Reference in New Issue