rsbuild-plugin-react-router 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/dist/index.cjs +4 -5
- package/dist/index.js +4 -5
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# rsbuild-plugin-react-router
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
4
|
<a href="https://rsbuild.dev" target="blank"><img src="https://github.com/web-infra-dev/rsbuild/assets/7237365/84abc13e-b620-468f-a90b-dbf28e7e9427" alt="Rsbuild Logo" /></a>
|
|
@@ -19,11 +19,11 @@ A Rsbuild plugin that provides seamless integration with React Router, supportin
|
|
|
19
19
|
## Installation
|
|
20
20
|
|
|
21
21
|
```bash
|
|
22
|
-
npm install
|
|
22
|
+
npm install rsbuild-plugin-react-router
|
|
23
23
|
# or
|
|
24
|
-
yarn add
|
|
24
|
+
yarn add rsbuild-plugin-react-router
|
|
25
25
|
# or
|
|
26
|
-
pnpm add
|
|
26
|
+
pnpm add rsbuild-plugin-react-router
|
|
27
27
|
```
|
|
28
28
|
|
|
29
29
|
## Usage
|
|
@@ -32,7 +32,7 @@ Add the plugin to your `rsbuild.config.ts`:
|
|
|
32
32
|
|
|
33
33
|
```ts
|
|
34
34
|
import { defineConfig } from '@rsbuild/core';
|
|
35
|
-
import { pluginReactRouter } from '
|
|
35
|
+
import { pluginReactRouter } from 'rsbuild-plugin-react-router';
|
|
36
36
|
import { pluginReact } from '@rsbuild/plugin-react';
|
|
37
37
|
|
|
38
38
|
export default defineConfig(() => {
|
|
@@ -208,7 +208,7 @@ The plugin supports two ways to handle server-side rendering:
|
|
|
208
208
|
```ts
|
|
209
209
|
// rsbuild.config.ts
|
|
210
210
|
import { defineConfig } from '@rsbuild/core';
|
|
211
|
-
import { pluginReactRouter } from '
|
|
211
|
+
import { pluginReactRouter } from 'rsbuild-plugin-react-router';
|
|
212
212
|
import { pluginReact } from '@rsbuild/plugin-react';
|
|
213
213
|
|
|
214
214
|
export default defineConfig(() => {
|
|
@@ -331,7 +331,7 @@ To deploy your React Router app to Cloudflare Workers:
|
|
|
331
331
|
```ts
|
|
332
332
|
import { defineConfig } from '@rsbuild/core';
|
|
333
333
|
import { pluginReact } from '@rsbuild/plugin-react';
|
|
334
|
-
import { pluginReactRouter } from '
|
|
334
|
+
import { pluginReactRouter } from 'rsbuild-plugin-react-router';
|
|
335
335
|
|
|
336
336
|
export default defineConfig({
|
|
337
337
|
environments: {
|
package/dist/index.cjs
CHANGED
|
@@ -302,7 +302,8 @@ export { ${output.exports.map((exp)=>'default' === exp ? 'defaultExport as defau
|
|
|
302
302
|
name: 'rsbuild:react-router',
|
|
303
303
|
async setup (api) {
|
|
304
304
|
var options1;
|
|
305
|
-
let clientStats
|
|
305
|
+
let clientStats;
|
|
306
|
+
let pluginOptions = {
|
|
306
307
|
customServer: !1,
|
|
307
308
|
serverOutput: 'module',
|
|
308
309
|
...options
|
|
@@ -326,9 +327,9 @@ export { ${output.exports.map((exp)=>'default' === exp ? 'defaultExport as defau
|
|
|
326
327
|
});
|
|
327
328
|
let jiti = (0, external_jiti_namespaceObject.createJiti)(process.cwd()), { appDirectory = 'app', basename = '/', buildDirectory = 'build', ssr = !0 } = await jiti.import('./react-router.config.ts', {
|
|
328
329
|
default: !0
|
|
329
|
-
}).catch(()=>(console.error('No react-router.config.ts found, using default configuration.'), {})), routesPath = (0, external_pathe_namespaceObject.resolve)(appDirectory, 'routes
|
|
330
|
+
}).catch(()=>(console.error('No react-router.config.ts found, using default configuration.'), {})), routesPath = findEntryFile((0, external_pathe_namespaceObject.resolve)(appDirectory, 'routes')), routeConfig = await jiti.import(routesPath, {
|
|
330
331
|
default: !0
|
|
331
|
-
}).catch((error)=>(console.error('Failed to load routes
|
|
332
|
+
}).catch((error)=>(console.error('Failed to load routes file:', error), console.error('No routes file found in app directory.'), [])), entryClientPath = findEntryFile((0, external_pathe_namespaceObject.resolve)(appDirectory, 'entry.client')), entryServerPath = findEntryFile((0, external_pathe_namespaceObject.resolve)(appDirectory, 'entry.server')), serverAppPath = findEntryFile((0, external_pathe_namespaceObject.resolve)(appDirectory, '../server/index')), hasServerApp = (0, external_node_fs_namespaceObject.existsSync)(serverAppPath), templateDir = (0, external_pathe_namespaceObject.resolve)(__dirname, 'templates'), templateClientPath = (0, external_pathe_namespaceObject.resolve)(templateDir, 'entry.client.js'), templateServerPath = (0, external_pathe_namespaceObject.resolve)(templateDir, 'entry.server.js'), finalEntryClientPath = (0, external_node_fs_namespaceObject.existsSync)(entryClientPath) ? entryClientPath : templateClientPath, finalEntryServerPath = (0, external_node_fs_namespaceObject.existsSync)(entryServerPath) ? entryServerPath : templateServerPath, routes = {
|
|
332
333
|
root: {
|
|
333
334
|
path: '',
|
|
334
335
|
id: 'root',
|
|
@@ -408,7 +409,6 @@ export { ${output.exports.map((exp)=>'default' === exp ? 'defaultExport as defau
|
|
|
408
409
|
const entryServer = new Proxy({}, {
|
|
409
410
|
get: (target, prop) => {
|
|
410
411
|
|
|
411
|
-
console.log(prop);
|
|
412
412
|
if (entryServerModule) {
|
|
413
413
|
return entryServerModule[prop];
|
|
414
414
|
}
|
|
@@ -417,7 +417,6 @@ export { ${output.exports.map((exp)=>'default' === exp ? 'defaultExport as defau
|
|
|
417
417
|
return createAsyncHandler(prop);
|
|
418
418
|
}
|
|
419
419
|
|
|
420
|
-
return entryServerModule[prop];
|
|
421
420
|
}
|
|
422
421
|
});
|
|
423
422
|
|
package/dist/index.js
CHANGED
|
@@ -287,7 +287,8 @@ let pluginReactRouter = (options = {})=>({
|
|
|
287
287
|
name: 'rsbuild:react-router',
|
|
288
288
|
async setup (api) {
|
|
289
289
|
var options1;
|
|
290
|
-
let clientStats
|
|
290
|
+
let clientStats;
|
|
291
|
+
let pluginOptions = {
|
|
291
292
|
customServer: !1,
|
|
292
293
|
serverOutput: 'module',
|
|
293
294
|
...options
|
|
@@ -311,9 +312,9 @@ let pluginReactRouter = (options = {})=>({
|
|
|
311
312
|
});
|
|
312
313
|
let jiti = (0, __WEBPACK_EXTERNAL_MODULE_jiti__.createJiti)(process.cwd()), { appDirectory = 'app', basename = '/', buildDirectory = 'build', ssr = !0 } = await jiti.import('./react-router.config.ts', {
|
|
313
314
|
default: !0
|
|
314
|
-
}).catch(()=>(console.error('No react-router.config.ts found, using default configuration.'), {})), routesPath = (0, __WEBPACK_EXTERNAL_MODULE_pathe__.resolve)(appDirectory, 'routes
|
|
315
|
+
}).catch(()=>(console.error('No react-router.config.ts found, using default configuration.'), {})), routesPath = findEntryFile((0, __WEBPACK_EXTERNAL_MODULE_pathe__.resolve)(appDirectory, 'routes')), routeConfig = await jiti.import(routesPath, {
|
|
315
316
|
default: !0
|
|
316
|
-
}).catch((error)=>(console.error('Failed to load routes
|
|
317
|
+
}).catch((error)=>(console.error('Failed to load routes file:', error), console.error('No routes file found in app directory.'), [])), entryClientPath = findEntryFile((0, __WEBPACK_EXTERNAL_MODULE_pathe__.resolve)(appDirectory, 'entry.client')), entryServerPath = findEntryFile((0, __WEBPACK_EXTERNAL_MODULE_pathe__.resolve)(appDirectory, 'entry.server')), serverAppPath = findEntryFile((0, __WEBPACK_EXTERNAL_MODULE_pathe__.resolve)(appDirectory, '../server/index')), hasServerApp = (0, __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.existsSync)(serverAppPath), templateDir = (0, __WEBPACK_EXTERNAL_MODULE_pathe__.resolve)(src_rslib_entry_dirname, 'templates'), templateClientPath = (0, __WEBPACK_EXTERNAL_MODULE_pathe__.resolve)(templateDir, 'entry.client.js'), templateServerPath = (0, __WEBPACK_EXTERNAL_MODULE_pathe__.resolve)(templateDir, 'entry.server.js'), finalEntryClientPath = (0, __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.existsSync)(entryClientPath) ? entryClientPath : templateClientPath, finalEntryServerPath = (0, __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__.existsSync)(entryServerPath) ? entryServerPath : templateServerPath, routes = {
|
|
317
318
|
root: {
|
|
318
319
|
path: '',
|
|
319
320
|
id: 'root',
|
|
@@ -393,7 +394,6 @@ let pluginReactRouter = (options = {})=>({
|
|
|
393
394
|
const entryServer = new Proxy({}, {
|
|
394
395
|
get: (target, prop) => {
|
|
395
396
|
|
|
396
|
-
console.log(prop);
|
|
397
397
|
if (entryServerModule) {
|
|
398
398
|
return entryServerModule[prop];
|
|
399
399
|
}
|
|
@@ -402,7 +402,6 @@ let pluginReactRouter = (options = {})=>({
|
|
|
402
402
|
return createAsyncHandler(prop);
|
|
403
403
|
}
|
|
404
404
|
|
|
405
|
-
return entryServerModule[prop];
|
|
406
405
|
}
|
|
407
406
|
});
|
|
408
407
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsbuild-plugin-react-router",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"description": "React Router plugin for Rsbuild",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -71,9 +71,9 @@
|
|
|
71
71
|
"@changesets/cli": "^2.28.1",
|
|
72
72
|
"@react-router/dev": "^7.4.0",
|
|
73
73
|
"@react-router/node": "^7.4.0",
|
|
74
|
-
"@rsbuild/core": "
|
|
74
|
+
"@rsbuild/core": "1.3.0-beta.2",
|
|
75
75
|
"@rslib/core": "^0.5.4",
|
|
76
|
-
"@rspack/core": "
|
|
76
|
+
"@rspack/core": "1.3.0-beta.1",
|
|
77
77
|
"@types/babel__core": "^7.6.8",
|
|
78
78
|
"@types/babel__generator": "^7.6.8",
|
|
79
79
|
"@types/babel__traverse": "^7.20.6",
|
|
@@ -96,7 +96,7 @@
|
|
|
96
96
|
"@rsbuild/config": "1.0.1"
|
|
97
97
|
},
|
|
98
98
|
"peerDependencies": {
|
|
99
|
-
"@rsbuild/core": "1.
|
|
99
|
+
"@rsbuild/core": "^1.3.0"
|
|
100
100
|
},
|
|
101
101
|
"publishConfig": {
|
|
102
102
|
"access": "public",
|
|
@@ -117,6 +117,6 @@
|
|
|
117
117
|
"changeset": "changeset",
|
|
118
118
|
"version": "changeset version",
|
|
119
119
|
"release": "changeset publish",
|
|
120
|
-
"release:local": "pnpm build && changeset version && changeset publish"
|
|
120
|
+
"release:local": "pnpm build && changeset version && changeset publish && git add . && git commit -m \"chore: version packages\" && git push && git push --tags"
|
|
121
121
|
}
|
|
122
122
|
}
|