-
Notifications
You must be signed in to change notification settings - Fork 386
feat(rspack-provider): support security.checkSyntax in Rspack #3685
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
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
652e02e
fix: support check-syntax in rspack
9aoy 81c763f
Merge branch 'main' of https://github.com/modern-js-dev/modern.js int…
9aoy ec14b7e
fix: lock
9aoy 9848c5c
docs: update checkSyntax doc
9aoy 6e6c303
fix: merge conflict
9aoy 2f4075a
fix: move security.sri from shared to webpack-provider
9aoy 2bda74c
fix: merge conflict
9aoy e8c70f6
fix: pure deps
9aoy a558145
fix: type SharedSecurityConfig
9aoy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| --- | ||
| '@modern-js/builder-rspack-provider': patch | ||
| '@modern-js/builder-shared': patch | ||
| '@modern-js/builder': patch | ||
| --- | ||
|
|
||
| feat(rspack-provider): support security.checkSyntax in Rspack | ||
|
|
||
| feat(rspack-provider): 在使用 Rspack 构建时支持 security.checkSyntax 配置项 |
This file contains hidden or 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 hidden or 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
20 changes: 6 additions & 14 deletions
20
packages/builder/builder-rspack-provider/src/types/config/security.ts
This file contains hidden or 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,16 +1,8 @@ | ||
| // Todo support security.sri configuration | ||
| /** | ||
| * Currently, rspack does not support the security.sri configuration. | ||
| * But it should because it's a shared configuration. | ||
| */ | ||
| // import type { SharedSecurityConfig } from '@modern-js/builder-shared'; | ||
| import type { | ||
| SharedSecurityConfig, | ||
| NormalizedSharedSecurityConfig, | ||
| } from '@modern-js/builder-shared'; | ||
|
|
||
| // export type SecurityConfig = SharedSecurityConfig; | ||
| export type SecurityConfig = SharedSecurityConfig; | ||
|
|
||
| // export type NormalizedSecurityConfig = Required<SecurityConfig>; | ||
|
|
||
| export interface SecurityConfig { | ||
| nonce?: string; | ||
| } | ||
|
|
||
| export type NormalizedSecurityConfig = Required<SecurityConfig>; | ||
| export type NormalizedSecurityConfig = NormalizedSharedSecurityConfig; |
This file contains hidden or 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
.../CheckSyntaxPlugin/helpers/printErrors.ts → .../CheckSyntaxPlugin/helpers/printErrors.ts
This file contains hidden or 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
File renamed without changes.
File renamed without changes.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
24 changes: 14 additions & 10 deletions
24
packages/builder/builder-webpack-provider/src/config/validate/security.ts
This file contains hidden or 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,17 +1,21 @@ | ||
| import { sharedSecurityConfigSchema, z } from '@modern-js/builder-shared'; | ||
| import { | ||
| sharedSecurityConfigSchema, | ||
| z, | ||
| SriOptions, | ||
| } from '@modern-js/builder-shared'; | ||
| import type { SecurityConfig } from '../../types'; | ||
|
|
||
| export const SriOptionsSchema: z.ZodType<SriOptions> = z.partialObj({ | ||
| hashFuncNames: z.array(z.string()).min(1) as unknown as z.ZodType< | ||
| [string, ...string[]] | ||
| >, | ||
| enabled: z.literals(['auto', true, false]), | ||
| hashLoading: z.literals(['eager', 'lazy']), | ||
| }); | ||
|
|
||
| export const securityConfigSchema: z.ZodType<SecurityConfig> = | ||
| sharedSecurityConfigSchema | ||
| .extend({ | ||
| checkSyntax: z.union([ | ||
| z.boolean(), | ||
| z.object({ | ||
| targets: z.array(z.string()), | ||
| exclude: z.optional( | ||
| z.union([z.instanceof(RegExp), z.array(z.instanceof(RegExp))]), | ||
| ), | ||
| }), | ||
| ]), | ||
| sri: z.union([SriOptionsSchema, z.boolean()]), | ||
| }) | ||
| .partial(); |
This file contains hidden or 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
21 changes: 12 additions & 9 deletions
21
packages/builder/builder-webpack-provider/src/types/config/security.ts
This file contains hidden or 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,13 +1,16 @@ | ||
| import type { SharedSecurityConfig } from '@modern-js/builder-shared'; | ||
|
|
||
| export interface CheckSyntaxOptions { | ||
| targets: string[]; | ||
| exclude?: RegExp | Array<RegExp>; | ||
| } | ||
| import type { | ||
| SriOptions, | ||
| SharedSecurityConfig, | ||
| NormalizedSharedSecurityConfig, | ||
| } from '@modern-js/builder-shared'; | ||
|
|
||
| export type SecurityConfig = SharedSecurityConfig & { | ||
| /** Analyze the product for the presence of high-level syntax that is not compatible in the specified environment */ | ||
| checkSyntax?: boolean | CheckSyntaxOptions; | ||
| /** | ||
| * Adding an integrity attribute (`integrity`) to sub-resources introduced by HTML allows the browser to | ||
| * verify the integrity of the introduced resource, thus preventing tampering with the downloaded resource. | ||
| */ | ||
| sri?: SriOptions | boolean; | ||
| }; | ||
|
|
||
| export type NormalizedSecurityConfig = Required<SecurityConfig>; | ||
| export type NormalizedSecurityConfig = NormalizedSharedSecurityConfig & | ||
| Required<Pick<SecurityConfig, 'sri'>>; |
21 changes: 0 additions & 21 deletions
21
packages/builder/builder-webpack-provider/tests/plugins/checkSyntax.test.ts
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.