Skip to content

Commit

Permalink
Merge branch 'main' into docs/eslint-doc
Browse files Browse the repository at this point in the history
  • Loading branch information
caohuilin committed Sep 11, 2024
2 parents 70eb330 + 4f19e98 commit 5600309
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 19 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
Original file line number Diff line number Diff line change
Expand Up @@ -462,8 +462,7 @@ For applications with higher performance requirements, prefetching can further e

:::tip

- This feature is currently only supported in Webpack projects and not in Rspack projects.
- Data preloading currently only preloads data returned by the [Data Loader](/guides/basic-features/data/data-fetch) in SSR projects.
Data preloading currently only preloads data returned by the [Data Loader](/guides/basic-features/data/data-fetch) in SSR projects.

:::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -464,8 +464,7 @@ Modern.js 支持通过 `loading.tsx` 文件来解决这个问题,`routes/` 下

:::tip

- 该功能目前仅在 Webpack 项目中支持,Rspack 项目暂不支持。
- 对数据的预加载目前只会预加载 SSR 项目中 [Data Loader](/guides/basic-features/data/data-fetch) 中返回的数据。
对数据的预加载目前只会预加载 SSR 项目中 [Data Loader](/guides/basic-features/data/data-fetch) 中返回的数据。

:::

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 @@ -27,7 +27,6 @@ interface PrefetchHandlers {
onTouchStart?: TouchEventHandler<Element>;
}

// TODO: 支持 rspack
declare const __webpack_chunk_load__:
| ((chunkId: string | number) => Promise<void>)
| undefined;
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 5600309

Please sign in to comment.