1 |
|
2 |
|
3 |
|
4 |
|
5 | "use strict";
|
6 |
|
7 | const RuntimeGlobals = require("../RuntimeGlobals");
|
8 | const Template = require("../Template");
|
9 | const HelperRuntimeModule = require("./HelperRuntimeModule");
|
10 |
|
11 | class CompatGetDefaultExportRuntimeModule extends HelperRuntimeModule {
|
12 | constructor() {
|
13 | super("compat get default export");
|
14 | }
|
15 |
|
16 | |
17 |
|
18 |
|
19 | generate() {
|
20 | const { runtimeTemplate } = this.compilation;
|
21 | const fn = RuntimeGlobals.compatGetDefaultExport;
|
22 | return Template.asString([
|
23 | "// getDefaultExport function for compatibility with non-harmony modules",
|
24 | `${fn} = ${runtimeTemplate.basicFunction("module", [
|
25 | "var getter = module && module.__esModule ?",
|
26 | Template.indent([
|
27 | `${runtimeTemplate.returningFunction("module['default']")} :`,
|
28 | `${runtimeTemplate.returningFunction("module")};`
|
29 | ]),
|
30 | `${RuntimeGlobals.definePropertyGetters}(getter, { a: getter });`,
|
31 | "return getter;"
|
32 | ])};`
|
33 | ]);
|
34 | }
|
35 | }
|
36 |
|
37 | module.exports = CompatGetDefaultExportRuntimeModule;
|