main
Last change
on this file was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 4 days ago |
F4 Finalna Verzija
|
-
Property mode
set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | /*
|
---|
2 | MIT License http://www.opensource.org/licenses/mit-license.php
|
---|
3 | */
|
---|
4 |
|
---|
5 | "use strict";
|
---|
6 |
|
---|
7 | const RuntimeGlobals = require("../RuntimeGlobals");
|
---|
8 | const Template = require("../Template");
|
---|
9 | const HelperRuntimeModule = require("./HelperRuntimeModule");
|
---|
10 |
|
---|
11 | /** @typedef {import("../Compilation")} Compilation */
|
---|
12 |
|
---|
13 | class CompatGetDefaultExportRuntimeModule extends HelperRuntimeModule {
|
---|
14 | constructor() {
|
---|
15 | super("compat get default export");
|
---|
16 | }
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * @returns {string | null} runtime code
|
---|
20 | */
|
---|
21 | generate() {
|
---|
22 | const compilation = /** @type {Compilation} */ (this.compilation);
|
---|
23 | const { runtimeTemplate } = compilation;
|
---|
24 | const fn = RuntimeGlobals.compatGetDefaultExport;
|
---|
25 | return Template.asString([
|
---|
26 | "// getDefaultExport function for compatibility with non-harmony modules",
|
---|
27 | `${fn} = ${runtimeTemplate.basicFunction("module", [
|
---|
28 | "var getter = module && module.__esModule ?",
|
---|
29 | Template.indent([
|
---|
30 | `${runtimeTemplate.returningFunction("module['default']")} :`,
|
---|
31 | `${runtimeTemplate.returningFunction("module")};`
|
---|
32 | ]),
|
---|
33 | `${RuntimeGlobals.definePropertyGetters}(getter, { a: getter });`,
|
---|
34 | "return getter;"
|
---|
35 | ])};`
|
---|
36 | ]);
|
---|
37 | }
|
---|
38 | }
|
---|
39 |
|
---|
40 | module.exports = CompatGetDefaultExportRuntimeModule;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.