Last change
on this file since 571e0df was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
972 bytes
|
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 | class MakeNamespaceObjectRuntimeModule extends HelperRuntimeModule {
|
---|
12 | constructor() {
|
---|
13 | super("make namespace object");
|
---|
14 | }
|
---|
15 |
|
---|
16 | /**
|
---|
17 | * @returns {string} runtime code
|
---|
18 | */
|
---|
19 | generate() {
|
---|
20 | const { runtimeTemplate } = this.compilation;
|
---|
21 | const fn = RuntimeGlobals.makeNamespaceObject;
|
---|
22 | return Template.asString([
|
---|
23 | "// define __esModule on exports",
|
---|
24 | `${fn} = ${runtimeTemplate.basicFunction("exports", [
|
---|
25 | "if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {",
|
---|
26 | Template.indent([
|
---|
27 | "Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });"
|
---|
28 | ]),
|
---|
29 | "}",
|
---|
30 | "Object.defineProperty(exports, '__esModule', { value: true });"
|
---|
31 | ])};`
|
---|
32 | ]);
|
---|
33 | }
|
---|
34 | }
|
---|
35 |
|
---|
36 | module.exports = MakeNamespaceObjectRuntimeModule;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.