-
-
Notifications
You must be signed in to change notification settings - Fork 595
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
88 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
packages/rspack-test-tools/tests/configCases/code-generation/path-ends-with-star/entry.mjs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import * as a from "./star*/a.js"; | ||
|
||
export const staticA = a; | ||
export const dynamicA = await import("./star*/a.js") | ||
export const dynamicA = await import("./star*/a.js") |
49 changes: 25 additions & 24 deletions
49
.../rspack-test-tools/tests/configCases/code-generation/path-ends-with-star/rspack.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
const isWindows = process.platform === "win32"; | ||
|
||
const entry = `it("should generate valid code", async () => {${isWindows | ||
? `expect("skip windows").toBe("skip windows");` | ||
: `const { staticA, dynamicA } = await import("./entry.mjs"); expect(staticA.a).toBe(1); expect(dynamicA.a).toBe(1);` | ||
}});`; | ||
const entry = `it("should generate valid code", async () => {${ | ||
isWindows | ||
? `expect("skip windows").toBe("skip windows");` | ||
: `const { staticA, dynamicA } = await import("./entry.mjs"); expect(staticA.a).toBe(1); expect(dynamicA.a).toBe(1);` | ||
}});`; | ||
|
||
/** @type {import("@rspack/core").Configuration} */ | ||
module.exports = { | ||
entry: `data:text/javascript,${entry}`, | ||
plugins: [ | ||
function skipWindows(compiler) { | ||
// windows' path can't include * | ||
if (!isWindows) { | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const dir = path.resolve(__dirname, "star*"); | ||
if (!fs.existsSync(dir)) { | ||
fs.mkdirSync(dir); | ||
} | ||
fs.writeFileSync(path.resolve(dir, "a.js"), "export const a = 1;"); | ||
// cleanup | ||
compiler.hooks.done.tap("skipWindows", () => { | ||
fs.rmSync(dir, { recursive: true, force: true }); | ||
}); | ||
} | ||
} | ||
] | ||
}; | ||
entry: `data:text/javascript,${entry}`, | ||
plugins: [ | ||
function skipWindows(compiler) { | ||
// windows' path can't include * | ||
if (!isWindows) { | ||
const fs = require("fs"); | ||
const path = require("path"); | ||
const dir = path.resolve(__dirname, "star*"); | ||
if (!fs.existsSync(dir)) { | ||
fs.mkdirSync(dir); | ||
} | ||
fs.writeFileSync(path.resolve(dir, "a.js"), "export const a = 1;"); | ||
// cleanup | ||
compiler.hooks.done.tap("skipWindows", () => { | ||
fs.rmSync(dir, { recursive: true, force: true }); | ||
}); | ||
} | ||
} | ||
] | ||
}; |