source: imaps-frontend/node_modules/webpack/lib/runtime/DefinePropertyGettersRuntimeModule.js@ 79a0317

main
Last change on this file since 79a0317 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
7const RuntimeGlobals = require("../RuntimeGlobals");
8const Template = require("../Template");
9const HelperRuntimeModule = require("./HelperRuntimeModule");
10
11/** @typedef {import("../Compilation")} Compilation */
12
13class DefinePropertyGettersRuntimeModule extends HelperRuntimeModule {
14 constructor() {
15 super("define property getters");
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.definePropertyGetters;
25 return Template.asString([
26 "// define getter functions for harmony exports",
27 `${fn} = ${runtimeTemplate.basicFunction("exports, definition", [
28 "for(var key in definition) {",
29 Template.indent([
30 `if(${RuntimeGlobals.hasOwnProperty}(definition, key) && !${RuntimeGlobals.hasOwnProperty}(exports, key)) {`,
31 Template.indent([
32 "Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });"
33 ]),
34 "}"
35 ]),
36 "}"
37 ])};`
38 ]);
39 }
40}
41
42module.exports = DefinePropertyGettersRuntimeModule;
Note: See TracBrowser for help on using the repository browser.