|
Last change
on this file since 9af201e was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
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 DefinePropertyGettersRuntimeModule extends HelperRuntimeModule {
|
|---|
| 14 | constructor() {
|
|---|
| 15 | super("define property getters");
|
|---|
| 16 | }
|
|---|
| 17 |
|
|---|
| 18 | /**
|
|---|
| 19 | * Generates runtime code for this runtime module.
|
|---|
| 20 | * @returns {string | null} runtime code
|
|---|
| 21 | */
|
|---|
| 22 | generate() {
|
|---|
| 23 | const compilation = /** @type {Compilation} */ (this.compilation);
|
|---|
| 24 | const { runtimeTemplate } = compilation;
|
|---|
| 25 | const fn = RuntimeGlobals.definePropertyGetters;
|
|---|
| 26 | return Template.asString([
|
|---|
| 27 | "// define getter functions for harmony exports",
|
|---|
| 28 | `${fn} = ${runtimeTemplate.basicFunction("exports, definition", [
|
|---|
| 29 | "for(var key in definition) {",
|
|---|
| 30 | Template.indent([
|
|---|
| 31 | `if(${RuntimeGlobals.hasOwnProperty}(definition, key) && !${RuntimeGlobals.hasOwnProperty}(exports, key)) {`,
|
|---|
| 32 | Template.indent([
|
|---|
| 33 | "Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });"
|
|---|
| 34 | ]),
|
|---|
| 35 | "}"
|
|---|
| 36 | ]),
|
|---|
| 37 | "}"
|
|---|
| 38 | ])};`
|
|---|
| 39 | ]);
|
|---|
| 40 | }
|
|---|
| 41 | }
|
|---|
| 42 |
|
|---|
| 43 | module.exports = DefinePropertyGettersRuntimeModule;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.