Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(rspack): move logic for withWeb to applyWebConfig and bring in line with webpack #28803

Merged
merged 9 commits into from
Nov 7, 2024
10 changes: 4 additions & 6 deletions docs/generated/packages/rspack/executors/rspack.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@
"type": "string",
"description": "The tsconfig file to build the project."
},
"typeCheck": {
"skipTypeChecking": {
"alias": "typeCheck",
"type": "boolean",
"description": "Skip the type checking."
},
"indexHtml": {
"type": "string",
"description": "The path to the index.html file."
"description": "Skip the type checking. Default is `false`."
},
"index": {
"alias": "indexHtml",
"type": "string",
"description": "HTML File which will be contain the application.",
"x-completion-type": "file",
Expand Down
10 changes: 7 additions & 3 deletions e2e/rspack/tests/rspack.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ describe('rspack e2e', () => {
});
expect(result).toContain('Successfully ran target build');
// Make sure expected files are present.
expect(listFiles(`dist/${project}`)).toHaveLength(5);
/**
* The files that are generated are:
* ["3rdpartylicenses.txt", "assets", "favicon.ico", "index.html", "main.bf7851e6.js", "runtime.e4294127.js"]
*/
expect(listFiles(`dist/${project}`)).toHaveLength(6);

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

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

result = runCLI(`test ${app2}`);
expect(result).toContain('Successfully ran target test');
Expand Down
3 changes: 2 additions & 1 deletion packages/rspack/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@
"@nx/workspace",
// Imported types only
"@module-federation/sdk",
"@module-federation/enhanced"
"@module-federation/enhanced",
"css-loader"
]
}
]
Expand Down
19 changes: 13 additions & 6 deletions packages/rspack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,27 @@
"@nx/devkit": "file:../devkit",
"@nx/web": "file:../web",
"@phenomnomnominal/tsquery": "~5.0.1",
"@rspack/core": "^1.0.4",
"@rspack/dev-server": "^1.0.4",
"@rspack/plugin-react-refresh": "^1.0.0",
"autoprefixer": "^10.4.9",
"chalk": "~4.1.0",
"css-loader": "^6.4.0",
"enquirer": "~2.3.6",
"express": "^4.19.2",
"http-proxy-middleware": "^3.0.3",
"less-loader": "11.1.0",
"license-webpack-plugin": "^4.0.2",
"loader-utils": "^2.0.3",
"sass": "^1.42.1",
"sass-loader": "^12.2.0",
"stylus-loader": "^7.1.0",
"style-loader": "^3.3.0",
"postcss-import": "~14.1.0",
"postcss-loader": "^8.1.1",
"@rspack/core": "^1.0.4",
"@rspack/dev-server": "^1.0.4",
"@rspack/plugin-react-refresh": "^1.0.0",
"chalk": "~4.1.0",
"postcss": "^8.4.38",
"tsconfig-paths": "^4.1.2",
"tslib": "^2.3.0"
"tslib": "^2.3.0",
"webpack-subresource-integrity": "^5.1.0"
},
"peerDependencies": {
"@module-federation/enhanced": "~0.6.0",
Expand Down
17 changes: 17 additions & 0 deletions packages/rspack/src/executors/rspack/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ export interface RspackExecutorSchema {
index?: string;
tsConfig?: string;
typeCheck?: boolean;
skipTypeChecking?: boolean;
outputPath?: string;
outputFileName?: string;
index?: string;
indexHtml?: string;
mode?: Mode;
watch?: boolean;
Expand All @@ -23,6 +25,13 @@ export interface RspackExecutorSchema {
generatePackageJson?: boolean;
}

export interface AssetGlobPattern {
glob: string;
input: string;
output: string;
ignore?: string[];
}

export interface FileReplacement {
replace: string;
with: string;
Expand All @@ -32,3 +41,11 @@ export interface OptimizationOptions {
scripts: boolean;
styles: boolean;
}

export interface NormalizedRspackExecutorSchema extends RspackExecutorSchema {
outputFileName: string;
assets: AssetGlobPattern[];
root: string;
projectRoot: string;
sourceRoot: string;
}
10 changes: 4 additions & 6 deletions packages/rspack/src/executors/rspack/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,13 @@
"type": "string",
"description": "The tsconfig file to build the project."
},
"typeCheck": {
"skipTypeChecking": {
"alias": "typeCheck",
"type": "boolean",
"description": "Skip the type checking."
},
"indexHtml": {
"type": "string",
"description": "The path to the index.html file."
"description": "Skip the type checking. Default is `false`."
},
"index": {
"alias": "indexHtml",
"type": "string",
"description": "HTML File which will be contain the application.",
"x-completion-type": "file",
Expand Down
Loading