source: imaps-frontend/node_modules/webpack/lib/dependencies/DynamicExports.js

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: 2.0 KB
Line 
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("../Module").BuildMeta} BuildMeta */
9/** @typedef {import("../Parser").ParserState} ParserState */
10
11/** @type {WeakMap<ParserState, boolean>} */
12const parserStateExportsState = new WeakMap();
13
14/**
15 * @param {ParserState} parserState parser state
16 * @returns {void}
17 */
18module.exports.bailout = parserState => {
19 const value = parserStateExportsState.get(parserState);
20 parserStateExportsState.set(parserState, false);
21 if (value === true) {
22 const buildMeta = /** @type {BuildMeta} */ (parserState.module.buildMeta);
23 buildMeta.exportsType = undefined;
24 buildMeta.defaultObject = false;
25 }
26};
27
28/**
29 * @param {ParserState} parserState parser state
30 * @returns {void}
31 */
32module.exports.enable = parserState => {
33 const value = parserStateExportsState.get(parserState);
34 if (value === false) return;
35 parserStateExportsState.set(parserState, true);
36 if (value !== true) {
37 const buildMeta = /** @type {BuildMeta} */ (parserState.module.buildMeta);
38 buildMeta.exportsType = "default";
39 buildMeta.defaultObject = "redirect";
40 }
41};
42
43/**
44 * @param {ParserState} parserState parser state
45 * @returns {void}
46 */
47module.exports.setFlagged = parserState => {
48 const value = parserStateExportsState.get(parserState);
49 if (value !== true) return;
50 const buildMeta = /** @type {BuildMeta} */ (parserState.module.buildMeta);
51 if (buildMeta.exportsType === "dynamic") return;
52 buildMeta.exportsType = "flagged";
53};
54
55/**
56 * @param {ParserState} parserState parser state
57 * @returns {void}
58 */
59module.exports.setDynamic = parserState => {
60 const value = parserStateExportsState.get(parserState);
61 if (value !== true) return;
62 /** @type {BuildMeta} */
63 (parserState.module.buildMeta).exportsType = "dynamic";
64};
65
66/**
67 * @param {ParserState} parserState parser state
68 * @returns {boolean} true, when enabled
69 */
70module.exports.isEnabled = parserState => {
71 const value = parserStateExportsState.get(parserState);
72 return value === true;
73};
Note: See TracBrowser for help on using the repository browser.