feat: refactoring project

This commit is contained in:
Carlos
2024-11-23 14:56:07 -05:00
parent f0c2a50c18
commit 1c6db5818d
2351 changed files with 39323 additions and 60326 deletions

View File

@@ -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) => {