Skip to content

Commit

Permalink
test: add test
Browse files Browse the repository at this point in the history
  • Loading branch information
LingyuCoder committed May 15, 2024
1 parent 54e103e commit 6cc1b48
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 18 deletions.
22 changes: 4 additions & 18 deletions packages/rspack-cli/tests/build/basic/public/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions packages/rspack-cli/tests/build/issue-6214/entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
const long_name_should_be_minified = process.env.NODE_ENV;
console.log(long_name_should_be_minified);
9 changes: 9 additions & 0 deletions packages/rspack-cli/tests/build/issue-6214/index.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { readFile, run } from "../../utils/test-utils";
import { resolve } from "path";

it("should not have `process.env.NODE_ENV` when optimization.nodeEnv has been set", async () => {
await run(__dirname, ["--mode", "production"]);
const mainJs = await readFile(resolve(__dirname, "dist/main.js"), "utf-8");
expect(mainJs).toContain("process.env.NODE_ENV");
expect(mainJs).not.toContain("long_name_should_be_minified");
});
14 changes: 14 additions & 0 deletions packages/rspack-cli/tests/build/issue-6214/rspack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
const path = require("path");

/** @type {import('@rspack/cli').Configuration} */
module.exports = {
mode: "development", // will be override to "production" by "--mode"
entry: "./entry.js",
output: {
clean: true,
path: path.resolve(__dirname, "dist")
},
optimization: {
nodeEnv: false
}
};

0 comments on commit 6cc1b48

Please sign in to comment.