Skip to content

Commit

Permalink
chore: rename serviceWorker environment name to workerSSR (#6210)
Browse files Browse the repository at this point in the history
  • Loading branch information
9aoy committed Sep 11, 2024
1 parent 8247b7d commit 4f19e98
Show file tree
Hide file tree
Showing 9 changed files with 20 additions and 14 deletions.
6 changes: 6 additions & 0 deletions .changeset/hot-jobs-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@modern-js/app-tools': patch
'@modern-js/uni-builder': patch
---

chore: rename serviceWorker environment name to workerSSR
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const pluginEnvironmentDefaults = (
// https://github.com/web-infra-dev/rsbuild/issues/2956
api.modifyRsbuildConfig({
handler: config => {
const environmentNameOrder = ['web', 'node', 'serviceWorker'];
const environmentNameOrder = ['web', 'node', 'workerSSR'];

config.environments = Object.fromEntries(
Object.entries(config.environments!).sort((a1, a2) =>
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/uni-builder/src/shared/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import browserslist from 'browserslist';

export const RUNTIME_CHUNK_NAME = 'builder-runtime';

export const SERVICE_WORKER_ENVIRONMENT_NAME = 'serviceWorker';
export const SERVICE_WORKER_ENVIRONMENT_NAME = 'workerSSR';

export const JS_REGEX = /\.(?:js|mjs|cjs|jsx)$/;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3303,7 +3303,7 @@ exports[`uni-builder rspack > should generator rspack config correctly when serv
},
],
},
"name": "serviceWorker",
"name": "workerSSR",
"optimization": {
"minimize": true,
"minimizer": [
Expand Down Expand Up @@ -3374,7 +3374,7 @@ exports[`uni-builder rspack > should generator rspack config correctly when serv
ProgressPlugin {
"_args": [
{
"prefix": "serviceWorker",
"prefix": "workerSSR",
},
],
"affectedHooks": undefined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2233,7 +2233,7 @@ exports[`uni-builder environment compat > should generator environment config co
},
],
},
"name": "serviceWorker",
"name": "workerSSR",
"optimization": {
"minimize": false,
"splitChunks": false,
Expand Down Expand Up @@ -2269,7 +2269,7 @@ exports[`uni-builder environment compat > should generator environment config co
ProgressPlugin {
"_args": [
{
"prefix": "serviceWorker",
"prefix": "workerSSR",
},
],
"affectedHooks": undefined,
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/uni-builder/tests/default.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ describe('uni-builder rspack', () => {
bundlerType: 'rspack',
config: {
environments: {
serviceWorker: {
workerSSR: {
output: {
target: 'web-worker',
},
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/uni-builder/tests/environment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('uni-builder environment compat', () => {
target: 'node',
},
},
serviceWorker: {
workerSSR: {
output: {
target: 'web-worker',
},
Expand All @@ -33,7 +33,7 @@ describe('uni-builder environment compat', () => {
expect(bundlerConfigs.map(c => c.name)).toEqual([
'web',
'node',
'serviceWorker',
'workerSSR',
]);

expect(bundlerConfigs).toMatchSnapshot();
Expand Down
2 changes: 1 addition & 1 deletion packages/runtime/plugin-runtime/src/cli/ssr/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const ssrBuilderPlugin = (modernAPI: PluginAPI<AppTools>): RsbuildPlugin => ({
setup(api) {
api.modifyEnvironmentConfig((config, { name, mergeEnvironmentConfig }) => {
const isServerEnvironment =
config.output.target === 'node' || name === 'serviceWorker';
config.output.target === 'node' || name === 'workerSSR';
const userConfig = modernAPI.useResolvedConfigContext();

const useLoadablePlugin =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ exports[`create builder Options test create builder environments config 2`] = `

exports[`create builder Options test create builder environments config 3`] = `
{
"serviceWorker": {
"web": {
"output": {
"target": "web-worker",
"target": "web",
},
"source": {
"entry": {
Expand All @@ -76,9 +76,9 @@ exports[`create builder Options test create builder environments config 3`] = `
},
},
},
"web": {
"workerSSR": {
"output": {
"target": "web",
"target": "web-worker",
},
"source": {
"entry": {
Expand Down

0 comments on commit 4f19e98

Please sign in to comment.