source: frontend/node_modules/webpack/lib/errors/EnvironmentNotSupportAsyncWarning.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Gengkun He @ahabhgk
4*/
5
6"use strict";
7
8const makeSerializable = require("../util/makeSerializable");
9const WebpackError = require("./WebpackError");
10
11/** @typedef {import("../Module")} Module */
12/** @typedef {import("../RuntimeTemplate")} RuntimeTemplate */
13/** @typedef {"asyncWebAssembly" | "topLevelAwait" | "external promise" | "external script" | "external import" | "external module"} Feature */
14
15class EnvironmentNotSupportAsyncWarning extends WebpackError {
16 /**
17 * Creates an instance of EnvironmentNotSupportAsyncWarning.
18 * @param {Module} module module
19 * @param {Feature} feature feature
20 */
21 constructor(module, feature) {
22 const message = `The generated code contains 'async/await' because this module is using "${feature}".
23However, your target environment does not appear to support 'async/await'.
24As a result, the code may not run as expected or may cause runtime errors.`;
25 super(message);
26
27 /** @type {string} */
28 this.name = "EnvironmentNotSupportAsyncWarning";
29 /** @type {Module} */
30 this.module = module;
31 }
32
33 /**
34 * Creates an instance of EnvironmentNotSupportAsyncWarning.
35 * @param {Module} module module
36 * @param {RuntimeTemplate} runtimeTemplate compilation
37 * @param {Feature} feature feature
38 */
39 static check(module, runtimeTemplate, feature) {
40 if (!runtimeTemplate.supportsAsyncFunction()) {
41 module.addWarning(new EnvironmentNotSupportAsyncWarning(module, feature));
42 }
43 }
44}
45
46makeSerializable(
47 EnvironmentNotSupportAsyncWarning,
48 "webpack/lib/errors/EnvironmentNotSupportAsyncWarning"
49);
50
51module.exports = EnvironmentNotSupportAsyncWarning;
Note: See TracBrowser for help on using the repository browser.