WXL
4 天以前 2cc85c64f1c64a2dbaeae276a3e2ca8420de76b7
node_modules/webpack/lib/ModuleParseError.js
@@ -8,6 +8,7 @@
const WebpackError = require("./WebpackError");
const makeSerializable = require("./util/makeSerializable");
/** @typedef {import("./Dependency").DependencyLocation} DependencyLocation */
/** @typedef {import("./Dependency").SourcePosition} SourcePosition */
/** @typedef {import("./serialization/ObjectMiddleware").ObjectDeserializerContext} ObjectDeserializerContext */
/** @typedef {import("./serialization/ObjectMiddleware").ObjectSerializerContext} ObjectSerializerContext */
@@ -16,6 +17,7 @@
class ModuleParseError extends WebpackError {
   /**
    * Creates an instance of ModuleParseError.
    * @param {string | Buffer} source source code
    * @param {Error & { loc?: SourcePosition }} err the parse error
    * @param {string[]} loaders the loaders used
@@ -23,10 +25,11 @@
    */
   constructor(source, err, loaders, type) {
      let message = `Module parse failed: ${err && err.message}`;
      /** @type {undefined | DependencyLocation} */
      let loc;
      if (
         ((Buffer.isBuffer(source) && source.slice(0, 4).equals(WASM_HEADER)) ||
         ((Buffer.isBuffer(source) && source.subarray(0, 4).equals(WASM_HEADER)) ||
            (typeof source === "string" && /^\0asm/.test(source))) &&
         !type.startsWith("webassembly")
      ) {
@@ -40,7 +43,8 @@
            "\nFor files that transpile to WebAssembly, make sure to set the module type in the 'module.rules' section of the config (e. g. 'type: \"webassembly/async\"').";
      } else if (!loaders) {
         message +=
            "\nYou may need an appropriate loader to handle this file type.";
            "\nYou may need an appropriate loader to handle this file type. " +
            "See https://webpack.js.org/concepts/loaders";
      } else if (loaders.length >= 1) {
         message += `\nFile was processed with these loaders:${loaders
            .map((loader) => `\n * ${loader}`)
@@ -88,12 +92,14 @@
      super(message);
      /** @type {string} */
      this.name = "ModuleParseError";
      this.loc = loc;
      this.error = err;
   }
   /**
    * Serializes this instance into the provided serializer context.
    * @param {ObjectSerializerContext} context context
    */
   serialize(context) {
@@ -105,6 +111,7 @@
   }
   /**
    * Restores this instance from the provided deserializer context.
    * @param {ObjectDeserializerContext} context context
    */
   deserialize(context) {