@rslib/core 0.5.1 → 0.5.2
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/dist/index.js +41 -39
- package/dist-types/plugins/shims.d.ts +0 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -160,7 +160,7 @@ function prepareCli() {
|
|
|
160
160
|
initNodeEnv();
|
|
161
161
|
const { npm_execpath } = process.env;
|
|
162
162
|
if (!npm_execpath || npm_execpath.includes('npx-cli.js') || npm_execpath.includes('.bun')) console.log();
|
|
163
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rslib v0.5.
|
|
163
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger.greet(` Rslib v0.5.2\n`);
|
|
164
164
|
}
|
|
165
165
|
const DEFAULT_CONFIG_NAME = 'rslib.config';
|
|
166
166
|
const DEFAULT_CONFIG_EXTENSIONS = [
|
|
@@ -493,45 +493,16 @@ const composeCssConfig = (rootDir, bundle = true, banner, footer)=>{
|
|
|
493
493
|
}
|
|
494
494
|
};
|
|
495
495
|
};
|
|
496
|
-
const
|
|
496
|
+
const EntryChunkPlugin_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
|
|
497
|
+
const EntryChunkPlugin_PLUGIN_NAME = 'rsbuild:lib-entry-chunk';
|
|
498
|
+
const EntryChunkPlugin_LOADER_NAME = 'rsbuild:lib-entry-module';
|
|
499
|
+
const IMPORT_META_URL_SHIM = `const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {
|
|
497
500
|
return typeof document === 'undefined'
|
|
498
501
|
? new (require('url'.replace('', '')).URL)('file:' + __filename).href
|
|
499
502
|
: (document.currentScript && document.currentScript.src) ||
|
|
500
503
|
new URL('main.js', document.baseURI).href;
|
|
501
504
|
})();
|
|
502
505
|
`;
|
|
503
|
-
const pluginCjsImportMetaUrlShim = ()=>({
|
|
504
|
-
name: 'rsbuild:cjs-import-meta-url-shim',
|
|
505
|
-
setup (api) {
|
|
506
|
-
api.modifyEnvironmentConfig((config)=>{
|
|
507
|
-
config.source.define = {
|
|
508
|
-
...config.source.define,
|
|
509
|
-
'import.meta.url': '__rslib_import_meta_url__'
|
|
510
|
-
};
|
|
511
|
-
});
|
|
512
|
-
}
|
|
513
|
-
});
|
|
514
|
-
const requireShim = `// Rslib ESM shims
|
|
515
|
-
import __rslib_shim_module__ from 'module';
|
|
516
|
-
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
|
|
517
|
-
`;
|
|
518
|
-
const pluginEsmRequireShim = ()=>({
|
|
519
|
-
name: 'rsbuild:esm-require-shim',
|
|
520
|
-
setup (api) {
|
|
521
|
-
api.modifyRspackConfig((config)=>{
|
|
522
|
-
config.plugins ??= [];
|
|
523
|
-
config.plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
|
|
524
|
-
banner: requireShim,
|
|
525
|
-
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE - 1,
|
|
526
|
-
raw: true,
|
|
527
|
-
include: /\.(js|cjs)$/
|
|
528
|
-
}));
|
|
529
|
-
});
|
|
530
|
-
}
|
|
531
|
-
});
|
|
532
|
-
const EntryChunkPlugin_require = (0, __WEBPACK_EXTERNAL_MODULE_node_module_ab9f2194__.createRequire)(import.meta.url);
|
|
533
|
-
const EntryChunkPlugin_PLUGIN_NAME = 'rsbuild:lib-entry-chunk';
|
|
534
|
-
const EntryChunkPlugin_LOADER_NAME = 'rsbuild:lib-entry-module';
|
|
535
506
|
const matchFirstLine = (source, regex)=>{
|
|
536
507
|
const lineBreakPos = source.match(/(\r\n|\n)/);
|
|
537
508
|
const firstLineContent = source.slice(0, lineBreakPos?.index);
|
|
@@ -541,6 +512,7 @@ const matchFirstLine = (source, regex)=>{
|
|
|
541
512
|
};
|
|
542
513
|
class EntryChunkPlugin {
|
|
543
514
|
reactDirectives = {};
|
|
515
|
+
shimsInjectedAssets = new Set();
|
|
544
516
|
shebangChmod = 493;
|
|
545
517
|
shebangEntries = {};
|
|
546
518
|
shebangInjectedAssets = new Set();
|
|
@@ -587,6 +559,7 @@ class EntryChunkPlugin {
|
|
|
587
559
|
if (!isJs) return;
|
|
588
560
|
const name = chunk.name;
|
|
589
561
|
if (!name) return;
|
|
562
|
+
this.shimsInjectedAssets.add(filename);
|
|
590
563
|
const shebangEntry = this.shebangEntries[name];
|
|
591
564
|
if (shebangEntry) this.shebangEntries[filename] = shebangEntry;
|
|
592
565
|
const reactDirective = this.reactDirectives[name];
|
|
@@ -596,12 +569,12 @@ class EntryChunkPlugin {
|
|
|
596
569
|
compiler.hooks.make.tap(EntryChunkPlugin_PLUGIN_NAME, (compilation)=>{
|
|
597
570
|
compilation.hooks.processAssets.tap(EntryChunkPlugin_PLUGIN_NAME, (assets)=>{
|
|
598
571
|
if (!this.enabledImportMetaUrlShim) return;
|
|
599
|
-
const chunkAsset = Object.keys(assets).filter((name)=>JS_EXTENSIONS_PATTERN.test(name));
|
|
572
|
+
const chunkAsset = Object.keys(assets).filter((name)=>JS_EXTENSIONS_PATTERN.test(name) && this.shimsInjectedAssets.has(name));
|
|
600
573
|
for (const name of chunkAsset)compilation.updateAsset(name, (old)=>{
|
|
601
574
|
const oldSource = old.source().toString();
|
|
602
575
|
const replaceSource = new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.sources.ReplaceSource(old);
|
|
603
|
-
if (oldSource.startsWith('use strict;') || oldSource.startsWith('"use strict";')) replaceSource.replace(0, 11, `"use strict";\n${
|
|
604
|
-
else replaceSource.insert(0,
|
|
576
|
+
if (oldSource.startsWith('use strict;') || oldSource.startsWith('"use strict";')) replaceSource.replace(0, 11, `"use strict";\n${IMPORT_META_URL_SHIM}`);
|
|
577
|
+
else replaceSource.insert(0, IMPORT_META_URL_SHIM);
|
|
605
578
|
return replaceSource;
|
|
606
579
|
});
|
|
607
580
|
});
|
|
@@ -653,6 +626,35 @@ const composeEntryChunkConfig = ({ enabledImportMetaUrlShim, contextToWatch = nu
|
|
|
653
626
|
}
|
|
654
627
|
}
|
|
655
628
|
});
|
|
629
|
+
const pluginCjsImportMetaUrlShim = ()=>({
|
|
630
|
+
name: 'rsbuild:cjs-import-meta-url-shim',
|
|
631
|
+
setup (api) {
|
|
632
|
+
api.modifyEnvironmentConfig((config)=>{
|
|
633
|
+
config.source.define = {
|
|
634
|
+
...config.source.define,
|
|
635
|
+
'import.meta.url': '__rslib_import_meta_url__'
|
|
636
|
+
};
|
|
637
|
+
});
|
|
638
|
+
}
|
|
639
|
+
});
|
|
640
|
+
const requireShim = `// Rslib ESM shims
|
|
641
|
+
import __rslib_shim_module__ from 'module';
|
|
642
|
+
const require = /*#__PURE__*/ __rslib_shim_module__.createRequire(import.meta.url);
|
|
643
|
+
`;
|
|
644
|
+
const pluginEsmRequireShim = ()=>({
|
|
645
|
+
name: 'rsbuild:esm-require-shim',
|
|
646
|
+
setup (api) {
|
|
647
|
+
api.modifyRspackConfig((config)=>{
|
|
648
|
+
config.plugins ??= [];
|
|
649
|
+
config.plugins.push(new __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.BannerPlugin({
|
|
650
|
+
banner: requireShim,
|
|
651
|
+
stage: __WEBPACK_EXTERNAL_MODULE__rsbuild_core_1b356efc__.rspack.Compilation.PROCESS_ASSETS_STAGE_OPTIMIZE - 1,
|
|
652
|
+
raw: true,
|
|
653
|
+
include: /\.(js|cjs)$/
|
|
654
|
+
}));
|
|
655
|
+
});
|
|
656
|
+
}
|
|
657
|
+
});
|
|
656
658
|
const getDefaultExtension = (options)=>{
|
|
657
659
|
const { format, pkgJson, autoExtension } = options;
|
|
658
660
|
let jsExtension = '.js';
|
|
@@ -2442,7 +2444,7 @@ const repeatableOption = (value, previous)=>(previous ?? []).concat([
|
|
|
2442
2444
|
value
|
|
2443
2445
|
]);
|
|
2444
2446
|
function runCli() {
|
|
2445
|
-
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.5.
|
|
2447
|
+
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.name('rslib').usage('<command> [options]').version("0.5.2");
|
|
2446
2448
|
const buildCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('build');
|
|
2447
2449
|
const inspectCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('inspect');
|
|
2448
2450
|
const mfDevCommand = __WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.command('mf-dev');
|
|
@@ -2503,6 +2505,6 @@ function runCli() {
|
|
|
2503
2505
|
});
|
|
2504
2506
|
__WEBPACK_EXTERNAL_MODULE__compiled_commander_index_js_bca3ceaa__.program.parse();
|
|
2505
2507
|
}
|
|
2506
|
-
const src_rslib_entry_version = "0.5.
|
|
2508
|
+
const src_rslib_entry_version = "0.5.2";
|
|
2507
2509
|
var __webpack_exports__logger = __WEBPACK_EXTERNAL_MODULE__compiled_rslog_index_js_c302f6e3__.logger;
|
|
2508
2510
|
export { build, defineConfig, inspect, loadConfig, prepareCli, runCli, startMFDevServer, composeCreateRsbuildConfig as unstable_composeCreateRsbuildConfig, src_rslib_entry_version as version, __webpack_exports__logger as logger };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { type RsbuildPlugin } from '@rsbuild/core';
|
|
2
|
-
export declare const importMetaUrlShim = "const __rslib_import_meta_url__ = /*#__PURE__*/ (function () {\n return typeof document === 'undefined'\n ? new (require('url'.replace('', '')).URL)('file:' + __filename).href\n : (document.currentScript && document.currentScript.src) ||\n new URL('main.js', document.baseURI).href;\n})();\n";
|
|
3
2
|
export declare const pluginCjsImportMetaUrlShim: () => RsbuildPlugin;
|
|
4
3
|
export declare const pluginEsmRequireShim: () => RsbuildPlugin;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rslib/core",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "The Rsbuild-based library development tool.",
|
|
5
5
|
"homepage": "https://lib.rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@rsbuild/core": "~1.2.10",
|
|
40
40
|
"tinyglobby": "^0.2.12",
|
|
41
|
-
"rsbuild-plugin-dts": "0.5.
|
|
41
|
+
"rsbuild-plugin-dts": "0.5.2"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@module-federation/rsbuild-plugin": "^0.
|
|
44
|
+
"@module-federation/rsbuild-plugin": "^0.9.0",
|
|
45
45
|
"@types/fs-extra": "^11.0.4",
|
|
46
46
|
"chokidar": "^4.0.3",
|
|
47
47
|
"commander": "^13.1.0",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"picocolors": "1.1.1",
|
|
51
51
|
"prebundle": "1.2.7",
|
|
52
52
|
"rsbuild-plugin-publint": "^0.3.0",
|
|
53
|
-
"rslib": "npm:@rslib/core@0.5.
|
|
53
|
+
"rslib": "npm:@rslib/core@0.5.1",
|
|
54
54
|
"rslog": "^1.2.3",
|
|
55
55
|
"tsconfck": "3.1.5",
|
|
56
56
|
"typescript": "^5.7.3",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
}
|
|
70
70
|
},
|
|
71
71
|
"engines": {
|
|
72
|
-
"node": ">=16.
|
|
72
|
+
"node": ">=16.7.0"
|
|
73
73
|
},
|
|
74
74
|
"publishConfig": {
|
|
75
75
|
"access": "public",
|