@lynx-js/external-bundle-rsbuild-plugin 0.2.0 → 0.3.0
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/CHANGELOG.md +6 -0
- package/lib/index.js +25 -18
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @lynx-js/external-bundle-rsbuild-plugin
|
|
2
2
|
|
|
3
|
+
## 0.3.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- Support Rsbuild v2 in the external bundle plugin by replacing the removed `dev.setupMiddlewares` integration with [`server.setup`](https://rsbuild.rs/guide/upgrade/v1-to-v2#others) and registering local external bundle asset middleware only during dev server startup. ([#2603](https://github.com/lynx-family/lynx-stack/pull/2603))
|
|
8
|
+
|
|
3
9
|
## 0.2.0
|
|
4
10
|
|
|
5
11
|
### Minor Changes
|
package/lib/index.js
CHANGED
|
@@ -395,24 +395,31 @@ export function pluginExternalBundle(options) {
|
|
|
395
395
|
return config;
|
|
396
396
|
}
|
|
397
397
|
return mergeRsbuildConfig(config, {
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
(
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
398
|
+
server: {
|
|
399
|
+
setup: ({ server, action }) => {
|
|
400
|
+
if (action !== 'dev') {
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
server.middlewares.use((req, res, next) => {
|
|
404
|
+
const bundlePath = req.url
|
|
405
|
+
? localBundleAssets.get(req.url)
|
|
406
|
+
: undefined;
|
|
407
|
+
if (bundlePath && existsSync(bundlePath)) {
|
|
408
|
+
res.setHeader('Content-Type', 'application/octet-stream');
|
|
409
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
410
|
+
const stream = createReadStream(bundlePath);
|
|
411
|
+
stream.on('error', () => {
|
|
412
|
+
if (!res.headersSent) {
|
|
413
|
+
res.statusCode = 404;
|
|
414
|
+
}
|
|
415
|
+
res.end();
|
|
416
|
+
});
|
|
417
|
+
stream.pipe(res);
|
|
418
|
+
return;
|
|
419
|
+
}
|
|
420
|
+
next();
|
|
421
|
+
});
|
|
422
|
+
},
|
|
416
423
|
},
|
|
417
424
|
});
|
|
418
425
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/external-bundle-rsbuild-plugin",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "An rsbuild plugin for loading lynx external bundles.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"rsbuild",
|
|
@@ -38,8 +38,8 @@
|
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@microsoft/api-extractor": "7.58.2",
|
|
41
|
-
"@rsbuild/core": "
|
|
42
|
-
"@lynx-js/react-umd": "0.121.
|
|
41
|
+
"@rsbuild/core": "2.0.11",
|
|
42
|
+
"@lynx-js/react-umd": "0.121.2"
|
|
43
43
|
},
|
|
44
44
|
"engines": {
|
|
45
45
|
"node": ">=18"
|