Skip to content

Commit

Permalink
fix(rspack): remove subresource integrity option
Browse files Browse the repository at this point in the history
  • Loading branch information
Coly010 committed Nov 12, 2024
1 parent 18d4a10 commit 3552126
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 22 deletions.
4 changes: 1 addition & 3 deletions packages/rspack/.eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,7 @@
// Imported types only
"@module-federation/sdk",
"@module-federation/enhanced",
"css-loader",
// required by webpack-subresource-integrity
"webpack"
"css-loader"
]
}
]
Expand Down
4 changes: 1 addition & 3 deletions packages/rspack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
"@rspack/core": "^1.0.4",
"@rspack/dev-server": "^1.0.4",
"@rspack/plugin-react-refresh": "^1.0.0",
"webpack": "^5.80.0",
"autoprefixer": "^10.4.9",
"browserslist": "^4.21.4",
"chalk": "~4.1.0",
Expand All @@ -51,8 +50,7 @@
"postcss-loader": "^8.1.1",
"postcss": "^8.4.38",
"tslib": "^2.3.0",
"webpack-node-externals": "^3.0.0",
"webpack-subresource-integrity": "^5.1.0"
"webpack-node-externals": "^3.0.0"
},
"peerDependencies": {
"@module-federation/enhanced": "~0.6.0",
Expand Down
13 changes: 3 additions & 10 deletions packages/rspack/src/plugins/utils/apply-web-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
} from '@rspack/core';
import { instantiateScriptPlugins } from './instantiate-script-plugins';
import { join, resolve } from 'path';
import { SubresourceIntegrityPlugin } from 'webpack-subresource-integrity';
import { getOutputHashFormat } from './hash-format';
import { normalizeExtraEntryPoints } from './normalize-entry';
import {
Expand Down Expand Up @@ -69,7 +68,7 @@ export function applyWebConfig(
plugins.push(
new HtmlRspackPlugin({
template: options.index,
sri: options.subresourceIntegrity ? 'sha256' : undefined,
sri: 'sha256',
...(options.baseHref ? { base: { href: options.baseHref } } : {}),
...(config.output?.scriptType === 'module'
? { scriptLoading: 'module' }
Expand All @@ -78,10 +77,6 @@ export function applyWebConfig(
);
}

if (options.subresourceIntegrity) {
plugins.push(new SubresourceIntegrityPlugin() as any);
}

const minimizer: RspackPluginInstance[] = [];
if (isProd && stylesOptimization) {
minimizer.push(
Expand Down Expand Up @@ -341,10 +336,8 @@ export function applyWebConfig(

config.output = {
...(config.output ?? {}),
assetModuleFilename: '[name].[contenthash:20][ext]',
crossOriginLoading: options.subresourceIntegrity
? ('anonymous' as const)
: (false as const),
assetModuleFilename: '[name].[contenthash:16][ext]',
crossOriginLoading: 'anonymous',
};

// In case users customize their rspack config with unsupported entry.
Expand Down
4 changes: 0 additions & 4 deletions packages/rspack/src/plugins/utils/models.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,10 +193,6 @@ export interface NxAppRspackPluginOptions {
* External stylesheets that will be included with the application.
*/
styles?: Array<ExtraEntryPointClass | string>;
/**
* Enables the use of subresource integrity validation.
*/
subresourceIntegrity?: boolean;
/**
* Override the `target` option in rspack configuration. This setting is not recommended and exists for backwards compatibility.
*/
Expand Down
1 change: 0 additions & 1 deletion packages/rspack/src/utils/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ function ensureNxRspackExecutionContext(ctx: NxRspackExecutionContext): void {
const configurationName = process.env.NX_TASK_TARGET_CONFIGURATION;
const projectGraph = readCachedProjectGraph();
const projectNode = projectGraph.nodes[projectName];
console.log('>>>DBG>>>', projectNode, projectName, projectNode.data.root);
ctx.options ??= {
root: workspaceRoot,
projectRoot: projectNode.data.root,
Expand Down
1 change: 0 additions & 1 deletion packages/rspack/src/utils/with-web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export interface WithWebOptions {
postcssConfig?: string;
scripts?: Array<ExtraEntryPointClass | string>;
styles?: Array<ExtraEntryPointClass | string>;
subresourceIntegrity?: boolean;
stylePreprocessorOptions?: {
includePaths?: string[];
};
Expand Down

0 comments on commit 3552126

Please sign in to comment.