feat: refactoring project
This commit is contained in:
24
node_modules/webpack/lib/dependencies/ImportMetaPlugin.js
generated
vendored
24
node_modules/webpack/lib/dependencies/ImportMetaPlugin.js
generated
vendored
@@ -49,9 +49,7 @@ class ImportMetaPlugin {
|
||||
* @param {NormalModule} module module
|
||||
* @returns {string} file url
|
||||
*/
|
||||
const getUrl = module => {
|
||||
return pathToFileURL(module.resource).toString();
|
||||
};
|
||||
const getUrl = module => pathToFileURL(module.resource).toString();
|
||||
/**
|
||||
* @param {Parser} parser parser parser
|
||||
* @param {JavascriptParserOptions} parserOptions parserOptions
|
||||
@@ -76,8 +74,8 @@ class ImportMetaPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
/// import.meta direct ///
|
||||
const webpackVersion = parseInt(
|
||||
// import.meta direct
|
||||
const webpackVersion = Number.parseInt(
|
||||
require("../../package.json").version,
|
||||
10
|
||||
);
|
||||
@@ -90,7 +88,7 @@ class ImportMetaPlugin {
|
||||
*/
|
||||
const importMetaUnknownProperty = members =>
|
||||
`${Template.toNormalComment(
|
||||
"unsupported import.meta." + members.join(".")
|
||||
`unsupported import.meta.${members.join(".")}`
|
||||
)} undefined${propertyAccess(members, 1)}`;
|
||||
parser.hooks.typeof
|
||||
.for("import.meta")
|
||||
@@ -162,7 +160,7 @@ class ImportMetaPlugin {
|
||||
evaluateToIdentifier("import.meta", "import.meta", () => [], true)
|
||||
);
|
||||
|
||||
/// import.meta.url ///
|
||||
// import.meta.url
|
||||
parser.hooks.typeof
|
||||
.for("import.meta.url")
|
||||
.tap(
|
||||
@@ -185,13 +183,13 @@ class ImportMetaPlugin {
|
||||
.tap(PLUGIN_NAME, evaluateToString("string"));
|
||||
parser.hooks.evaluateIdentifier
|
||||
.for("import.meta.url")
|
||||
.tap(PLUGIN_NAME, expr => {
|
||||
return new BasicEvaluatedExpression()
|
||||
.tap(PLUGIN_NAME, expr =>
|
||||
new BasicEvaluatedExpression()
|
||||
.setString(getUrl(parser.state.module))
|
||||
.setRange(/** @type {Range} */ (expr.range));
|
||||
});
|
||||
.setRange(/** @type {Range} */ (expr.range))
|
||||
);
|
||||
|
||||
/// import.meta.webpack ///
|
||||
// import.meta.webpack
|
||||
parser.hooks.typeof
|
||||
.for("import.meta.webpack")
|
||||
.tap(
|
||||
@@ -211,7 +209,7 @@ class ImportMetaPlugin {
|
||||
.for("import.meta.webpack")
|
||||
.tap(PLUGIN_NAME, evaluateToNumber(webpackVersion));
|
||||
|
||||
/// Unknown properties ///
|
||||
// Unknown properties
|
||||
parser.hooks.unhandledExpressionMemberChain
|
||||
.for("import.meta")
|
||||
.tap(PLUGIN_NAME, (expr, members) => {
|
||||
|
||||
Reference in New Issue
Block a user