Skip to content

Commit 17e8eed

Browse files
committed
add test case
1 parent c09e82f commit 17e8eed

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-0
lines changed

lib/dependencies/ImportMetaPlugin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class ImportMetaPlugin {
5252
const parserHandler = (parser, { importMeta }) => {
5353
if (importMeta === false) {
5454
const { importMetaName } = compilation.outputOptions;
55+
if (importMetaName === "import.meta") return;
5556

5657
parser.hooks.expression
5758
.for("import.meta")
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const url = import.meta.url;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { url } from "./a";
2+
3+
it("should evaluate import.meta to pseudoImport.meta", () => {
4+
expect(url).toBe("http://test.co/path/index.js");
5+
});
6+
7+
it("should evaluate import.meta in runtime", () => {
8+
expect(url).toBe(import.meta.url);
9+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
module.exports = {
2+
moduleScope(scope) {
3+
scope.pseudoImport = { meta: { url: "http://test.co/path/index.js" } };
4+
}
5+
};
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/** @type {import("../../../../").Configuration} */
2+
module.exports = {
3+
output: {
4+
importMetaName: "pseudoImport.meta"
5+
},
6+
module: {
7+
parser: {
8+
javascript: {
9+
importMeta: false
10+
}
11+
}
12+
}
13+
};

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy