UNPKG

1.2 kBJavaScriptView Raw
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8/** @typedef {import("../Parser").ParserState} ParserState */
9
10/** @type {WeakMap<ParserState, boolean>} */
11const parserStateExportsState = new WeakMap();
12
13/**
14 * @param {ParserState} parserState parser state
15 * @param {boolean} isStrictHarmony strict harmony mode should be enabled
16 * @returns {void}
17 */
18exports.enable = (parserState, isStrictHarmony) => {
19 const value = parserStateExportsState.get(parserState);
20 if (value === false) return;
21 parserStateExportsState.set(parserState, true);
22 if (value !== true) {
23 parserState.module.buildMeta.exportsType = "namespace";
24 parserState.module.buildInfo.strict = true;
25 parserState.module.buildInfo.exportsArgument = "__webpack_exports__";
26 if (isStrictHarmony) {
27 parserState.module.buildMeta.strictHarmonyModule = true;
28 parserState.module.buildInfo.moduleArgument = "__webpack_module__";
29 }
30 }
31};
32
33/**
34 * @param {ParserState} parserState parser state
35 * @returns {boolean} true, when enabled
36 */
37exports.isEnabled = parserState => {
38 const value = parserStateExportsState.get(parserState);
39 return value === true;
40};