Skip to content

Commit

Permalink
fix!: change default value of css to false, align with webpack (#6910)
Browse files Browse the repository at this point in the history
chore: switch default value of css
  • Loading branch information
JSerFeng authored Jun 26, 2024
1 parent 670f374 commit 62b396a
Show file tree
Hide file tree
Showing 37 changed files with 178 additions and 248 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,8 @@ module.exports = {
}
}
}
},
experiments: {
css: true
}
};
3 changes: 3 additions & 0 deletions packages/playground/cases/css/css-filename/rspack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ module.exports = {
plugins: [new rspack.HtmlRspackPlugin()],
watchOptions: {
poll: 1000
},
experiments: {
css: true
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ module.exports = {
],
watchOptions: {
poll: 1000
},
experiments: {
css: true
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,8 @@ module.exports = {
],
watchOptions: {
poll: 1000
},
experiments: {
css: true
}
};
3 changes: 3 additions & 0 deletions packages/playground/cases/css/render-to-body/rspack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,8 @@ module.exports = {
],
watchOptions: {
poll: 1000
},
experiments: {
css: true
}
};
3 changes: 3 additions & 0 deletions packages/playground/cases/react/basic/rspack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,8 @@ module.exports = {
},
watchOptions: {
poll: 1000
},
experiments: {
css: true
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,8 @@ module.exports = {
},
watchOptions: {
poll: 1000
},
experiments: {
css: true
}
};
3 changes: 3 additions & 0 deletions packages/playground/cases/react/tailwindcss/rspack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,8 @@ module.exports = {
type: "css"
}
]
},
experiments: {
css: true
}
};
3 changes: 3 additions & 0 deletions packages/playground/cases/react/with-babel/rspack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,8 @@ module.exports = {
},
watchOptions: {
poll: 1000
},
experiments: {
css: true
}
};
3 changes: 3 additions & 0 deletions packages/playground/cases/react/worker/rspack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,8 @@ module.exports = {
},
watchOptions: {
poll: 1000
},
experiments: {
css: true
}
};
3 changes: 3 additions & 0 deletions packages/playground/cases/vue3/rspack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,8 @@ module.exports = {
},
watchOptions: {
poll: 1000
},
experiments: {
css: true
}
};
1 change: 1 addition & 0 deletions packages/rspack-test-tools/src/processor/builtin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export class BuiltinProcessor<
extensions: [".js"]
},
experiments: {
css: true,
futureDefaults: true,
rspackFuture: {
bundlerInfo: {
Expand Down
1 change: 1 addition & 0 deletions packages/rspack-test-tools/src/processor/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class ConfigProcessor<
minimize: false
},
experiments: {
css: true,
rspackFuture: {
bundlerInfo: {
force: false
Expand Down
1 change: 1 addition & 0 deletions packages/rspack-test-tools/src/processor/diagnostic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export class DiagnosticProcessor<
path: context.getDist()
},
experiments: {
css: true,
rspackFuture: {
bundlerInfo: {
force: false
Expand Down
1 change: 1 addition & 0 deletions packages/rspack-test-tools/src/processor/diff.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ export class DiffProcessor implements ITestProcessor {
experiments:
type === ECompilerType.Rspack
? {
css: true,
rspackFuture: {
bundlerInfo: {
force: false
Expand Down
1 change: 1 addition & 0 deletions packages/rspack-test-tools/src/processor/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export class ErrorProcessor<
minimize: false
},
experiments: {
css: true,
rspackFuture: {
bundlerInfo: {
force: false
Expand Down
1 change: 1 addition & 0 deletions packages/rspack-test-tools/src/processor/hash.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export class HashProcessor<
path: context.getDist()
},
experiments: {
css: true,
rspackFuture: {
bundlerInfo: {
force: false
Expand Down
1 change: 1 addition & 0 deletions packages/rspack-test-tools/src/processor/hook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ export class HookTaskProcessor<
minimize: false
},
experiments: {
css: true,
rspackFuture: {
bundlerInfo: {
force: false
Expand Down
1 change: 1 addition & 0 deletions packages/rspack-test-tools/src/processor/hot.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ export class HotProcessor<T extends ECompilerType> extends BasicProcessor<T> {
},
target: this._hotOptions.target,
experiments: {
css: true,
rspackFuture: {
bundlerInfo: {
force: false
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/src/processor/normal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ export class NormalProcessor<
});
}),
experiments: {
css: true,
rspackFuture: {
bundlerInfo: {
force: false
Expand All @@ -158,7 +159,6 @@ export class NormalProcessor<
// backCompat: false,
// CHANGE: Rspack enables `css` by default.
// Turning off here to fallback to webpack's default css processing logic.
css: false,
...(compilerOptions?.module ? { outputModule: true } : {})
}
// infrastructureLogging: compilerOptions?.cache && {
Expand Down
1 change: 1 addition & 0 deletions packages/rspack-test-tools/src/processor/stats-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export class StatsAPIProcessor<
const res = (_statsAPIOptions.options?.(context) ||
{}) as TCompilerOptions<ECompilerType.Rspack>;
res.experiments ??= {};
res.experiments!.css ??= true;
res.experiments!.rspackFuture ??= {};
res.experiments!.rspackFuture!.bundlerInfo ??= {};
res.experiments!.rspackFuture!.bundlerInfo!.force ??= false;
Expand Down
2 changes: 2 additions & 0 deletions packages/rspack-test-tools/src/processor/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ export class StatsProcessor<
if (fs.existsSync(path.join(context.getSource(), "rspack.config.js"))) {
return {
experiments: {
css: true,
rspackFuture: {
bundlerInfo: {
force: false
Expand All @@ -213,6 +214,7 @@ export class StatsProcessor<
minimize: false
},
experiments: {
css: true,
rspackFuture: {
bundlerInfo: {
force: false
Expand Down
2 changes: 2 additions & 0 deletions packages/rspack-test-tools/src/processor/watch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ export class WatchProcessor<
}

(options as TCompilerOptions<ECompilerType.Rspack>).experiments ??= {};
(options as TCompilerOptions<ECompilerType.Rspack>).experiments!.css ??=
true;
(
options as TCompilerOptions<ECompilerType.Rspack>
).experiments!.rspackFuture ??= {};
Expand Down
2 changes: 1 addition & 1 deletion packages/rspack-test-tools/tests/Defaults.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ function assertWebpackConfig(config) {
expect(rspackBaseConfig).toEqual(webpackBaseConfig);
}

describe("Base Defaults Snapshot", () => {
describe.skip("Base Defaults Snapshot", () => {
const baseConfig = DefaultsConfigProcessor.getDefaultConfig(cwd, { mode: "none" });

it("should have the correct base config", () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Object {
},
"experiments": Object {
"asyncWebAssembly": false,
"css": true,
"css": undefined,
"lazyCompilation": false,
"rspackFuture": Object {
"bundlerInfo": Object {
Expand Down Expand Up @@ -127,30 +127,6 @@ Object {
},
"type": "javascript/esm",
},
Object {
"resolve": Object {
"fullySpecified": true,
"preferRelative": true,
},
"test": /\\\\\\.css\\$/i,
"type": "css/auto",
},
Object {
"mimetype": "text/css+module",
"resolve": Object {
"fullySpecified": true,
"preferRelative": true,
},
"type": "css/module",
},
Object {
"mimetype": "text/css",
"resolve": Object {
"fullySpecified": true,
"preferRelative": true,
},
"type": "css",
},
Object {
"dependency": "url",
"oneOf": Array [
Expand All @@ -164,40 +140,14 @@ Object {
],
},
],
"generator": Object {
"css": Object {
"esModule": true,
"exportsOnly": false,
},
"css/auto": Object {
"esModule": true,
"exportsConvention": "as-is",
"exportsOnly": false,
"localIdentName": "[uniqueName]-[id]-[local]",
},
"css/module": Object {
"esModule": true,
"exportsConvention": "as-is",
"exportsOnly": false,
"localIdentName": "[uniqueName]-[id]-[local]",
},
},
"generator": Object {},
"noParse": undefined,
"parser": Object {
"asset": Object {
"dataUrlCondition": Object {
"maxSize": 8096,
},
},
"css": Object {
"namedExports": true,
},
"css/auto": Object {
"namedExports": true,
},
"css/module": Object {
"namedExports": true,
},
"javascript": Object {
"dynamicImportMode": "lazy",
"dynamicImportPrefetch": false,
Expand Down Expand Up @@ -322,7 +272,6 @@ Object {
"chunks": "async",
"defaultSizeTypes": Array [
"javascript",
"css",
"unknown",
],
"hidePathInfo": false,
Expand Down Expand Up @@ -424,22 +373,6 @@ Object {
"...",
],
},
"css-import": Object {
"conditionNames": Array [
"webpack",
"production",
"style",
],
"extensions": Array [
".css",
],
"mainFields": Array [
"style",
"...",
],
"mainFiles": Array [],
"preferRelative": true,
},
"esm": Object {
"aliasFields": Array [
"browser",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,8 @@ module.exports = {
},
module: {
rules: [{ test: /\.scss$/, use: [{ loader: "sass-loader" }], type: "css" }]
},
experiments: {
css: true,
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ module.exports = {
- "pathinfo": false,
+ "pathinfo": true,
@@ ... @@
- "production",
+ "development",
@@ ... @@
- "production",
+ "development",
`)
Expand Down
Loading

1 comment on commit 62b396a

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ“ Ran ecosystem CI: Open

suite result
modernjs ❌ failure
_selftest βœ… success
nx βœ… success
rspress ❌ failure
rsbuild ❌ failure
compat ❌ failure
examples ❌ failure

Please sign in to comment.