Skip to content

Commit fd2e8d0

Browse files
authored
feat(rspack): move logic for withWeb to applyWebConfig and bring in line with webpack (#28803)
<!-- Please make sure you have read the submission guidelines before posting an PR --> <!-- https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr --> <!-- Please make sure that your commit message follows our format --> <!-- Example: `fix(nx): must begin with lowercase` --> <!-- If this is a particularly complex change or feature addition, you can request a dedicated Nx release for this pull request branch. Mention someone from the Nx team or the `@nrwl/nx-pipelines-reviewers` and they will confirm if the PR warrants its own release for testing purposes, and generate it for you if appropriate. --> ## Current Behavior <!-- This is the behavior we have today --> `withWeb` from `@nx/rspack` is not reflective of what `@nx/webpack` does. ## Expected Behavior <!-- This is the behavior we should expect with the changes in this PR --> Bring `withWeb` in line with `@nx/webpack` ## Related Issue(s) <!-- Please link the issue being fixed so it gets closed when this is merged. --> Fixes #
1 parent 2c9fc57 commit fd2e8d0

25 files changed

+1501
-161
lines changed

docs/generated/packages/rspack/executors/rspack.json

+4-6
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@
2626
"type": "string",
2727
"description": "The tsconfig file to build the project."
2828
},
29-
"typeCheck": {
29+
"skipTypeChecking": {
30+
"alias": "typeCheck",
3031
"type": "boolean",
31-
"description": "Skip the type checking."
32-
},
33-
"indexHtml": {
34-
"type": "string",
35-
"description": "The path to the index.html file."
32+
"description": "Skip the type checking. Default is `false`."
3633
},
3734
"index": {
35+
"alias": "indexHtml",
3836
"type": "string",
3937
"description": "HTML File which will be contain the application.",
4038
"x-completion-type": "file",

e2e/rspack/tests/rspack.spec.ts

+7-3
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,11 @@ describe('rspack e2e', () => {
6565
});
6666
expect(result).toContain('Successfully ran target build');
6767
// Make sure expected files are present.
68-
expect(listFiles(`dist/${project}`)).toHaveLength(5);
68+
/**
69+
* The files that are generated are:
70+
* ["3rdpartylicenses.txt", "assets", "favicon.ico", "index.html", "main.bf7851e6.js", "runtime.e4294127.js"]
71+
*/
72+
expect(listFiles(`dist/${project}`)).toHaveLength(6);
6973

7074
result = runCLI(`test ${project}`);
7175
expect(result).toContain('Successfully ran target test');
@@ -83,7 +87,7 @@ describe('rspack e2e', () => {
8387
env: { NODE_ENV: 'production' },
8488
});
8589
expect(result).toContain('Successfully ran target build');
86-
expect(listFiles(`dist/${project}`)).toHaveLength(5); // same length as before
90+
expect(listFiles(`dist/${project}`)).toHaveLength(6); // same length as before
8791

8892
// Generate a new app and check that the files are correct
8993
const app2 = uniq('app2');
@@ -116,7 +120,7 @@ describe('rspack e2e', () => {
116120
});
117121
expect(result).toContain('Successfully ran target build');
118122
// Make sure expected files are present.
119-
expect(listFiles(`dist/${app2}`)).toHaveLength(5);
123+
expect(listFiles(`dist/${app2}`)).toHaveLength(6);
120124

121125
result = runCLI(`test ${app2}`);
122126
expect(result).toContain('Successfully ran target test');

packages/rspack/.eslintrc.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@
3939
"@nx/workspace",
4040
// Imported types only
4141
"@module-federation/sdk",
42-
"@module-federation/enhanced"
42+
"@module-federation/enhanced",
43+
"css-loader"
4344
]
4445
}
4546
]

packages/rspack/package.json

+13-6
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,27 @@
2828
"@nx/devkit": "file:../devkit",
2929
"@nx/web": "file:../web",
3030
"@phenomnomnominal/tsquery": "~5.0.1",
31+
"@rspack/core": "^1.0.4",
32+
"@rspack/dev-server": "^1.0.4",
33+
"@rspack/plugin-react-refresh": "^1.0.0",
34+
"autoprefixer": "^10.4.9",
35+
"chalk": "~4.1.0",
36+
"css-loader": "^6.4.0",
3137
"enquirer": "~2.3.6",
3238
"express": "^4.19.2",
3339
"http-proxy-middleware": "^3.0.3",
3440
"less-loader": "11.1.0",
3541
"license-webpack-plugin": "^4.0.2",
42+
"loader-utils": "^2.0.3",
43+
"sass": "^1.42.1",
3644
"sass-loader": "^12.2.0",
37-
"stylus-loader": "^7.1.0",
45+
"style-loader": "^3.3.0",
46+
"postcss-import": "~14.1.0",
3847
"postcss-loader": "^8.1.1",
39-
"@rspack/core": "^1.0.4",
40-
"@rspack/dev-server": "^1.0.4",
41-
"@rspack/plugin-react-refresh": "^1.0.0",
42-
"chalk": "~4.1.0",
48+
"postcss": "^8.4.38",
4349
"tsconfig-paths": "^4.1.2",
44-
"tslib": "^2.3.0"
50+
"tslib": "^2.3.0",
51+
"webpack-subresource-integrity": "^5.1.0"
4552
},
4653
"peerDependencies": {
4754
"@module-federation/enhanced": "~0.6.0",

packages/rspack/src/executors/rspack/schema.d.ts

+17
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ export interface RspackExecutorSchema {
66
index?: string;
77
tsConfig?: string;
88
typeCheck?: boolean;
9+
skipTypeChecking?: boolean;
910
outputPath?: string;
1011
outputFileName?: string;
12+
index?: string;
1113
indexHtml?: string;
1214
mode?: Mode;
1315
watch?: boolean;
@@ -23,6 +25,13 @@ export interface RspackExecutorSchema {
2325
generatePackageJson?: boolean;
2426
}
2527

28+
export interface AssetGlobPattern {
29+
glob: string;
30+
input: string;
31+
output: string;
32+
ignore?: string[];
33+
}
34+
2635
export interface FileReplacement {
2736
replace: string;
2837
with: string;
@@ -32,3 +41,11 @@ export interface OptimizationOptions {
3241
scripts: boolean;
3342
styles: boolean;
3443
}
44+
45+
export interface NormalizedRspackExecutorSchema extends RspackExecutorSchema {
46+
outputFileName: string;
47+
assets: AssetGlobPattern[];
48+
root: string;
49+
projectRoot: string;
50+
sourceRoot: string;
51+
}

packages/rspack/src/executors/rspack/schema.json

+4-6
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,13 @@
2626
"type": "string",
2727
"description": "The tsconfig file to build the project."
2828
},
29-
"typeCheck": {
29+
"skipTypeChecking": {
30+
"alias": "typeCheck",
3031
"type": "boolean",
31-
"description": "Skip the type checking."
32-
},
33-
"indexHtml": {
34-
"type": "string",
35-
"description": "The path to the index.html file."
32+
"description": "Skip the type checking. Default is `false`."
3633
},
3734
"index": {
35+
"alias": "indexHtml",
3836
"type": "string",
3937
"description": "HTML File which will be contain the application.",
4038
"x-completion-type": "file",

0 commit comments

Comments
 (0)