Skip to content

Commit 863f8df

Browse files
authored
feat(rspack-provider): support security.checkSyntax in Rspack (#3685)
* fix: support check-syntax in rspack * fix: lock * docs: update checkSyntax doc * fix: move security.sri from shared to webpack-provider * fix: pure deps * fix: type SharedSecurityConfig
1 parent 0a6b969 commit 863f8df

File tree

37 files changed

+281
-1157
lines changed

37 files changed

+281
-1157
lines changed

.changeset/gentle-adults-move.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
'@modern-js/builder-rspack-provider': patch
3+
'@modern-js/builder-shared': patch
4+
'@modern-js/builder': patch
5+
---
6+
7+
feat(rspack-provider): support security.checkSyntax in Rspack
8+
9+
feat(rspack-provider): 在使用 Rspack 构建时支持 security.checkSyntax 配置项

packages/builder/builder-rspack-provider/src/config/defaults.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const createDefaultConfig = () =>
2222
output: getDefaultOutputConfig(),
2323
tools: {},
2424
security: {
25+
checkSyntax: false,
2526
nonce: '',
2627
// sri: false
2728
},

packages/builder/builder-rspack-provider/src/shared/plugin.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@ export const applyDefaultPlugins = (plugins: Plugins) =>
4343
plugins.inlineChunk(),
4444
plugins.bundleAnalyzer(),
4545
plugins.assetsRetry(),
46+
plugins.checkSyntax(),
4647
import('../plugins/fallback').then(m => m.builderPluginFallback()), // fallback should be the last plugin
4748
]);
Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
// Todo support security.sri configuration
2-
/**
3-
* Currently, rspack does not support the security.sri configuration.
4-
* But it should because it's a shared configuration.
5-
*/
6-
// import type { SharedSecurityConfig } from '@modern-js/builder-shared';
1+
import type {
2+
SharedSecurityConfig,
3+
NormalizedSharedSecurityConfig,
4+
} from '@modern-js/builder-shared';
75

8-
// export type SecurityConfig = SharedSecurityConfig;
6+
export type SecurityConfig = SharedSecurityConfig;
97

10-
// export type NormalizedSecurityConfig = Required<SecurityConfig>;
11-
12-
export interface SecurityConfig {
13-
nonce?: string;
14-
}
15-
16-
export type NormalizedSecurityConfig = Required<SecurityConfig>;
8+
export type NormalizedSecurityConfig = NormalizedSharedSecurityConfig;

packages/builder/builder-shared/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@
9696
"@modern-js/types": "workspace:*",
9797
"@modern-js/utils": "workspace:*",
9898
"@babel/core": "^7.21.8",
99+
"acorn": "^8.8.1",
100+
"caniuse-lite": "^1.0.30001451",
101+
"cheerio": "1.0.0-rc.12",
102+
"source-map": "^0.7.4",
99103
"webpack-sources": "^3.2.3",
100104
"zod": "^3.20.2",
101105
"zod-validation-error": "^0.3.0"
@@ -104,6 +108,7 @@
104108
"@babel/preset-env": "^7.21.5",
105109
"@scripts/vitest-config": "workspace:*",
106110
"@types/babel__core": "^7.20.0",
111+
"@types/caniuse-lite": "^1.0.1",
107112
"@types/node": "^14",
108113
"html-webpack-plugin": "5.5.0",
109114
"terser": "^5.14.1",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { SyntaxError } from './type';
22
import chalk from '@modern-js/utils/chalk';
3-
import { logger } from '@modern-js/builder-shared';
3+
import { logger } from '../../../logger';
44

55
type Error = {
66
source: string;

0 commit comments

Comments
 (0)