@rollipop/rolldown 1.0.20 → 1.0.22
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/cli.mjs +11 -8
- package/dist/config.d.mts +15 -2
- package/dist/config.mjs +2 -2
- package/dist/experimental-index.d.mts +8 -8
- package/dist/experimental-index.mjs +16 -13
- package/dist/filter-index.d.mts +1 -1
- package/dist/filter-index.mjs +2 -2
- package/dist/get-log-filter.d.mts +1 -1
- package/dist/get-log-filter.mjs +2 -2
- package/dist/index.d.mts +3 -3
- package/dist/index.mjs +11 -5
- package/dist/parallel-plugin-worker.mjs +5 -4
- package/dist/parallel-plugin.d.mts +1 -1
- package/dist/parse-ast-index.d.mts +1 -1
- package/dist/parse-ast-index.mjs +2 -2
- package/dist/plugins-index.d.mts +3 -3
- package/dist/plugins-index.mjs +2 -2
- package/dist/shared/{binding-DamCAbY6.mjs → binding-9kL0gFYL.mjs} +28 -27
- package/dist/shared/{binding-DE7ERejD.d.mts → binding-CckXxUel.d.mts} +53 -4
- package/dist/shared/{bindingify-input-options-SGSGV3Kn.mjs → bindingify-input-options-3NuL6LmT.mjs} +35 -21
- package/dist/shared/{constructors-CTfc5fh7.mjs → constructors-BR7PP67a.mjs} +1 -1
- package/dist/shared/{constructors-CqnDcrIL.d.mts → constructors-CZDP-zxV.d.mts} +2 -2
- package/dist/shared/{define-config-xmEHQczI.d.mts → define-config-BdEm3DW7.d.mts} +108 -12
- package/dist/shared/dist-DKbukT1H.mjs +154 -0
- package/dist/shared/{error-BmTEI0xY.mjs → error-D2KvICgd.mjs} +1 -1
- package/dist/shared/{get-log-filter-BpNVNJ5-.d.mts → get-log-filter-B4LpBryx.d.mts} +2 -2
- package/dist/shared/{load-config-DY5kAiwf.mjs → load-config-C-H6Sxai.mjs} +19 -2
- package/dist/shared/{logs-aMKUxRpj.mjs → logs-ZGEh6uhb.mjs} +6 -1
- package/dist/shared/{normalize-string-or-regex-Ddbkskw6.mjs → normalize-string-or-regex-BzQ-7a-8.mjs} +2 -2
- package/dist/shared/{parse-CNsctGYH.mjs → parse-CanHtd_6.mjs} +2 -2
- package/dist/shared/{prompt-B1Yc1NPt.mjs → prompt--dNycKSZ.mjs} +59 -17
- package/dist/shared/{resolve-tsconfig-B6udNjE_.mjs → resolve-tsconfig-Bx74P5AA.mjs} +2 -2
- package/dist/shared/{rolldown-C6DTtWMe.mjs → rolldown-BCi17Yn9.mjs} +2 -2
- package/dist/shared/{rolldown-build-BCVOvLca.mjs → rolldown-build-BjB3v1c2.mjs} +43 -17
- package/dist/shared/{transform-DiNoOk6R.d.mts → transform-C20O3Ind.d.mts} +1 -1
- package/dist/shared/{watch-BqeQlZnt.mjs → watch-BilISOyp.mjs} +6 -6
- package/dist/utils-index.d.mts +5 -5
- package/dist/utils-index.mjs +10 -8
- package/package.json +14 -13
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as RolldownLog, i as RolldownError, n as LogLevelOption, o as RolldownLogWithString, r as LogOrStringHandler, t as LogLevel } from "./logging-BSNejiLS.mjs";
|
|
2
|
-
import { F as JsxOptions, H as PreRenderedChunk, I as MinifyOptions$1,
|
|
2
|
+
import { F as JsxOptions$1, H as PreRenderedChunk, I as MinifyOptions$1, M as ExternalMemoryStatus, U as ReactRefreshOptions$1, V as ParserOptions, _ as BindingTransformHookExtraArgs, c as BindingHookResolveIdExtraArgs, d as BindingPluginContextResolveOptions, j as BindingWatcherBundler, p as BindingRenderedChunk, q as TransformOptions$1, t as BindingBuiltinPluginName, u as BindingMagicString, z as OxcReactCompilerOptions } from "./binding-CckXxUel.mjs";
|
|
3
3
|
import { TopLevelFilterExpression } from "@rolldown/pluginutils";
|
|
4
4
|
import { Program } from "@oxc-project/types";
|
|
5
5
|
|
|
@@ -420,6 +420,22 @@ interface OutputOptions {
|
|
|
420
420
|
*/
|
|
421
421
|
sourcemapBaseUrl?: string;
|
|
422
422
|
/**
|
|
423
|
+
* The pattern to use for sourcemaps created from entry points, or a function that is called per entry chunk with {@linkcode PreRenderedChunk} to return such a pattern.
|
|
424
|
+
*
|
|
425
|
+
* Patterns support the following placeholders:
|
|
426
|
+
* - `[format]`: The rendering format defined in the output options. The value is any of {@linkcode InternalModuleFormat}.
|
|
427
|
+
* - `[hash]`: A hash based only on the content of the final generated sourcemap. You can also set a specific hash length via e.g. `[hash:10]`. By default, it will create a base-64 hash. If you need a reduced character set, see {@linkcode hashCharacters | output.hashCharacters}.
|
|
428
|
+
* - `[chunkhash]`: The same hash as the one used for the corresponding generated chunk (if any).
|
|
429
|
+
* - `[name]`: The name of the corresponding chunk.
|
|
430
|
+
*
|
|
431
|
+
* Forward slashes (`/`) can be used to place files in sub-directories. This pattern will also be used for every file when setting the {@linkcode preserveModules | output.preserveModules} option.
|
|
432
|
+
*
|
|
433
|
+
* See also {@linkcode assetFileNames | output.assetFileNames}, {@linkcode chunkFileNames | output.chunkFileNames}.
|
|
434
|
+
*
|
|
435
|
+
* @default the corresponding chunk filename with `.map` appended
|
|
436
|
+
*/
|
|
437
|
+
sourcemapFileNames?: string | ChunkFileNamesFunction;
|
|
438
|
+
/**
|
|
423
439
|
* Whether to include [debug IDs](https://github.com/tc39/ecma426/blob/main/proposals/debug-id.md) in the sourcemap.
|
|
424
440
|
*
|
|
425
441
|
* When `true`, a unique debug ID will be emitted in source and sourcemaps which streamlines identifying sourcemaps across different builds.
|
|
@@ -1304,7 +1320,7 @@ declare class RolldownBuild {
|
|
|
1304
1320
|
*
|
|
1305
1321
|
* @example
|
|
1306
1322
|
* ```js
|
|
1307
|
-
* import { rolldown } from 'rolldown';
|
|
1323
|
+
* import { rolldown } from '@rollipop/rolldown';
|
|
1308
1324
|
*
|
|
1309
1325
|
* {
|
|
1310
1326
|
* using bundle = await rolldown({ input: 'src/main.js' });
|
|
@@ -1335,7 +1351,7 @@ declare class RolldownBuild {
|
|
|
1335
1351
|
*
|
|
1336
1352
|
* @example
|
|
1337
1353
|
* ```js
|
|
1338
|
-
* import { rolldown } from 'rolldown';
|
|
1354
|
+
* import { rolldown } from '@rollipop/rolldown';
|
|
1339
1355
|
*
|
|
1340
1356
|
* let bundle, failed = false;
|
|
1341
1357
|
* try {
|
|
@@ -1445,7 +1461,7 @@ interface RolldownWatcher {
|
|
|
1445
1461
|
*
|
|
1446
1462
|
* @example
|
|
1447
1463
|
* ```js
|
|
1448
|
-
* import { watch } from 'rolldown';
|
|
1464
|
+
* import { watch } from '@rollipop/rolldown';
|
|
1449
1465
|
*
|
|
1450
1466
|
* const watcher = watch({ /* ... *\/ });
|
|
1451
1467
|
* watcher.on('event', (event) => {
|
|
@@ -1529,6 +1545,9 @@ interface ChecksOptions {
|
|
|
1529
1545
|
* Annotations placed where they cannot annotate a call expression (e.g. before a non-call expression,
|
|
1530
1546
|
* before a statement declaration, or between an identifier and `=` in a variable declarator) are
|
|
1531
1547
|
* ignored by the parser. Matches Rollup's `INVALID_ANNOTATION` log code.
|
|
1548
|
+
*
|
|
1549
|
+
* By default, warnings are emitted only for local project files inside `cwd` and outside
|
|
1550
|
+
* `node_modules`. Set this option to `false` to disable the warning entirely.
|
|
1532
1551
|
* @default true
|
|
1533
1552
|
* */
|
|
1534
1553
|
invalidAnnotation?: boolean;
|
|
@@ -1659,6 +1678,26 @@ interface ChecksOptions {
|
|
|
1659
1678
|
}
|
|
1660
1679
|
//#endregion
|
|
1661
1680
|
//#region src/options/transform-options.d.ts
|
|
1681
|
+
interface ReactRefreshOptions extends ReactRefreshOptions$1 {
|
|
1682
|
+
/**
|
|
1683
|
+
* File patterns to transform. Empty means all files that enter the transform pipeline.
|
|
1684
|
+
*/
|
|
1685
|
+
include?: StringOrRegExp | StringOrRegExp[];
|
|
1686
|
+
/**
|
|
1687
|
+
* File patterns to skip.
|
|
1688
|
+
*/
|
|
1689
|
+
exclude?: StringOrRegExp | StringOrRegExp[];
|
|
1690
|
+
}
|
|
1691
|
+
interface JsxOptions extends Omit<JsxOptions$1, "refresh"> {
|
|
1692
|
+
/**
|
|
1693
|
+
* Enable React Fast Refresh.
|
|
1694
|
+
*/
|
|
1695
|
+
refresh?: boolean | ReactRefreshOptions;
|
|
1696
|
+
/**
|
|
1697
|
+
* Enable React Compiler.
|
|
1698
|
+
*/
|
|
1699
|
+
compiler?: OxcReactCompilerOptions;
|
|
1700
|
+
}
|
|
1662
1701
|
interface TransformOptions extends Omit<TransformOptions$1, "sourceType" | "lang" | "cwd" | "sourcemap" | "define" | "inject" | "jsx"> {
|
|
1663
1702
|
/**
|
|
1664
1703
|
* Replace global variables or [property accessors](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Property_accessors) with the provided values.
|
|
@@ -1769,7 +1808,6 @@ interface TransformOptions extends Omit<TransformOptions$1, "sourceType" | "lang
|
|
|
1769
1808
|
* - If set to `'preserve'`, JSX syntax will be preserved as-is.
|
|
1770
1809
|
*/
|
|
1771
1810
|
jsx?: false | "react" | "react-jsx" | "preserve" | JsxOptions;
|
|
1772
|
-
reactCompiler?: OxcReactCompilerOptions;
|
|
1773
1811
|
}
|
|
1774
1812
|
//#endregion
|
|
1775
1813
|
//#region src/options/normalized-input-options.d.ts
|
|
@@ -1806,6 +1844,8 @@ interface NormalizedOutputOptions {
|
|
|
1806
1844
|
dir: string | undefined;
|
|
1807
1845
|
/** @see {@linkcode OutputOptions.entryFileNames | entryFileNames} */
|
|
1808
1846
|
entryFileNames: string | ChunkFileNamesFunction;
|
|
1847
|
+
/** @see {@linkcode OutputOptions.sourcemapFileNames | sourcemapFileNames} */
|
|
1848
|
+
sourcemapFileNames: string | ChunkFileNamesFunction | undefined;
|
|
1809
1849
|
/** @see {@linkcode OutputOptions.chunkFileNames | chunkFileNames} */
|
|
1810
1850
|
chunkFileNames: string | ChunkFileNamesFunction;
|
|
1811
1851
|
/** @see {@linkcode OutputOptions.assetFileNames | assetFileNames} */
|
|
@@ -2627,8 +2667,8 @@ type OverrideFilterObject = {
|
|
|
2627
2667
|
* @example
|
|
2628
2668
|
* ```ts
|
|
2629
2669
|
* import yaml from '@rollup/plugin-yaml';
|
|
2630
|
-
* import { defineConfig } from 'rolldown';
|
|
2631
|
-
* import { withFilter } from 'rolldown/filter';
|
|
2670
|
+
* import { defineConfig } from '@rollipop/rolldown';
|
|
2671
|
+
* import { withFilter } from '@rollipop/rolldown/filter';
|
|
2632
2672
|
*
|
|
2633
2673
|
* export default defineConfig({
|
|
2634
2674
|
* plugins: [
|
|
@@ -2652,6 +2692,28 @@ type ModuleSideEffects = boolean | "no-treeshake" | null;
|
|
|
2652
2692
|
type ModuleType = "js" | "jsx" | "ts" | "tsx" | "json" | "text" | "base64" | "dataurl" | "binary" | "empty" | (string & {});
|
|
2653
2693
|
/** @category Plugin APIs */
|
|
2654
2694
|
type ImportKind = BindingHookResolveIdExtraArgs["kind"];
|
|
2695
|
+
/**
|
|
2696
|
+
* Descriptive metadata a plugin can expose about itself.
|
|
2697
|
+
*
|
|
2698
|
+
* Set it via the {@linkcode Plugin.meta | meta} property of the plugin object.
|
|
2699
|
+
*
|
|
2700
|
+
* @category Plugin APIs
|
|
2701
|
+
*/
|
|
2702
|
+
interface PluginMeta {
|
|
2703
|
+
/**
|
|
2704
|
+
* The name of the npm package the plugin ships in, e.g. `@vitejs/plugin-vue`.
|
|
2705
|
+
*/
|
|
2706
|
+
packageName?: string;
|
|
2707
|
+
/**
|
|
2708
|
+
* The version of the npm package the plugin ships in, e.g. `5.0.0`. The
|
|
2709
|
+
* `version` field of that package's `package.json`.
|
|
2710
|
+
*/
|
|
2711
|
+
version?: string;
|
|
2712
|
+
/**
|
|
2713
|
+
* A short, human-readable description of what the plugin does.
|
|
2714
|
+
*/
|
|
2715
|
+
description?: string;
|
|
2716
|
+
}
|
|
2655
2717
|
/** @category Plugin APIs */
|
|
2656
2718
|
interface CustomPluginOptions {
|
|
2657
2719
|
[plugin: string]: any;
|
|
@@ -2661,6 +2723,31 @@ interface ModuleOptions {
|
|
|
2661
2723
|
moduleSideEffects: ModuleSideEffects;
|
|
2662
2724
|
/** See [Custom module meta-data section](https://rolldown.rs/apis/plugin-api/inter-plugin-communication#custom-module-meta-data) for more details. */
|
|
2663
2725
|
meta: CustomPluginOptions;
|
|
2726
|
+
/**
|
|
2727
|
+
* A short, human-readable description of the module.
|
|
2728
|
+
*
|
|
2729
|
+
* This is useful for virtual modules, whose ids (e.g.
|
|
2730
|
+
* `\0vite/modulepreload-polyfill.js`) do not convey their purpose on their own.
|
|
2731
|
+
*
|
|
2732
|
+
* @example
|
|
2733
|
+
* ```js
|
|
2734
|
+
* function polyfillPlugin() {
|
|
2735
|
+
* return {
|
|
2736
|
+
* name: 'vite:modulepreload-polyfill',
|
|
2737
|
+
* load: {
|
|
2738
|
+
* filter: { id: /^\0vite\/modulepreload-polyfill\.js$/ },
|
|
2739
|
+
* handler(id) {
|
|
2740
|
+
* return {
|
|
2741
|
+
* code: '',
|
|
2742
|
+
* description: 'A polyfill for `link` tag with `rel="modulepreload"`',
|
|
2743
|
+
* };
|
|
2744
|
+
* }
|
|
2745
|
+
* },
|
|
2746
|
+
* };
|
|
2747
|
+
* }
|
|
2748
|
+
* ```
|
|
2749
|
+
*/
|
|
2750
|
+
description?: string;
|
|
2664
2751
|
invalidate?: boolean;
|
|
2665
2752
|
packageJsonPath?: string;
|
|
2666
2753
|
}
|
|
@@ -3090,6 +3177,15 @@ interface OutputPlugin extends Partial<{ [K in keyof PluginHooks as K & OutputPl
|
|
|
3090
3177
|
name: string;
|
|
3091
3178
|
/** The version of the plugin, for use in inter-plugin communication scenarios. */
|
|
3092
3179
|
version?: string;
|
|
3180
|
+
/**
|
|
3181
|
+
* Descriptive metadata about the plugin, such as the npm package it ships in.
|
|
3182
|
+
*
|
|
3183
|
+
* This does not affect bundling; it is informational and intended to be
|
|
3184
|
+
* surfaced by tooling that inspects a build. See {@linkcode PluginMeta}.
|
|
3185
|
+
*
|
|
3186
|
+
* @experimental
|
|
3187
|
+
*/
|
|
3188
|
+
meta?: PluginMeta;
|
|
3093
3189
|
}
|
|
3094
3190
|
/**
|
|
3095
3191
|
* The Plugin interface.
|
|
@@ -3371,7 +3467,7 @@ interface InputOptions {
|
|
|
3371
3467
|
*
|
|
3372
3468
|
* @example
|
|
3373
3469
|
* ```js
|
|
3374
|
-
* import { defineConfig } from 'rolldown'
|
|
3470
|
+
* import { defineConfig } from '@rollipop/rolldown'
|
|
3375
3471
|
*
|
|
3376
3472
|
* export default defineConfig({
|
|
3377
3473
|
* plugins: [
|
|
@@ -3575,7 +3671,7 @@ interface InputOptions {
|
|
|
3575
3671
|
*
|
|
3576
3672
|
* @example
|
|
3577
3673
|
* ```js
|
|
3578
|
-
* import { defineConfig } from 'rolldown'
|
|
3674
|
+
* import { defineConfig } from '@rollipop/rolldown'
|
|
3579
3675
|
*
|
|
3580
3676
|
* export default defineConfig({
|
|
3581
3677
|
* moduleTypes: {
|
|
@@ -3776,7 +3872,7 @@ interface InputOptions {
|
|
|
3776
3872
|
* describing your use case so we can address it before the option is gone.
|
|
3777
3873
|
*
|
|
3778
3874
|
* @see {@link https://rolldown.rs/in-depth/lazy-barrel-optimization | Lazy Barrel Documentation}
|
|
3779
|
-
* @default
|
|
3875
|
+
* @default false
|
|
3780
3876
|
*/
|
|
3781
3877
|
lazyBarrel?: boolean;
|
|
3782
3878
|
};
|
|
@@ -3892,7 +3988,7 @@ type RolldownOptionsFunction = (commandLineArguments: Record<string, any>) => Ma
|
|
|
3892
3988
|
*
|
|
3893
3989
|
* @example
|
|
3894
3990
|
* ```js [rolldown.config.js]
|
|
3895
|
-
* import { defineConfig } from 'rolldown';
|
|
3991
|
+
* import { defineConfig } from '@rollipop/rolldown';
|
|
3896
3992
|
*
|
|
3897
3993
|
* export default defineConfig({
|
|
3898
3994
|
* input: 'src/main.js',
|
|
@@ -3909,4 +4005,4 @@ declare function defineConfig(config: RolldownOptions[]): RolldownOptions[];
|
|
|
3909
4005
|
declare function defineConfig(config: RolldownOptionsFunction): RolldownOptionsFunction;
|
|
3910
4006
|
declare function defineConfig(config: ConfigExport): ConfigExport;
|
|
3911
4007
|
//#endregion
|
|
3912
|
-
export {
|
|
4008
|
+
export { MinimalPluginContext as $, SourcemapIgnoreListOption as $t, RolldownPlugin as A, ChunkingContext as At, SourceMapInput as B, OutputOptions as Bt, ParallelPluginHooks as C, BuildOptions as Ct, ResolveIdExtraOptions as D, AdvancedChunksOptions as Dt, PluginMeta as E, AdvancedChunksGroup as Et, BuiltinPlugin as F, GeneratedCodeOptions as Ft, EmittedChunk as G, OutputAsset as Gt, TreeshakingOptions as H, MaybePromise as Ht, RUNTIME_MODULE_ID as I, GeneratedCodePreset as It, GetModuleInfo as J, RenderedModule as Jt, EmittedFile as K, OutputChunk as Kt, VERSION as L, GlobalsFunction as Lt, SourceDescription as M, CodeSplittingNameFunction as Mt, TransformResult as N, CodeSplittingOptions as Nt, ResolveIdResult as O, BuiltinModuleTag as Ot, withFilter as P, CommentsOptions as Pt, defineParallelPlugin as Q, ModuleInfo as Qt, BundleError as R, MinifyOptions as Rt, ObjectHook as S, RolldownBuild as St, Plugin as T, AddonFunction as Tt, TransformPluginContext as U, PartialNull as Ut, OutputBundle as V, PreRenderedAsset as Vt, EmittedAsset as W, StringOrRegExp as Wt, PluginContextResolveOptions as X, SourceMap as Xt, PluginContext as Y, RolldownOutput as Yt, DefineParallelPluginResult as Z, freeExternalMemory as Zt, HookFilterExtension as _, RolldownWatcher as _t, ChunkOptimizationOptions as a, RolldownDirectoryEntry as at, ModuleOptions as b, WatchOptions as bt, InputOption as c, InternalModuleFormat as ct, OptimizationOptions as d, TransformOptions as dt, PluginContextMeta as et, WatcherFileWatcherOptions as f, ChecksOptions as ft, FunctionPluginHooks as g, watch as gt, CustomPluginOptions as h, RolldownMagicString as ht, RolldownOptions as i, BufferEncoding as it, RolldownPluginOption as j, CodeSplittingGroup as jt, ResolvedId as k, ChunkFileNamesFunction as kt, InputOptions as l, NormalizedOutputOptions as lt, AsyncPluginHooks as m, WarningHandlerWithDefault as mt, RolldownOptionsFunction as n, HookFilter as nt, ExternalOption as o, RolldownFileStats as ot, WatcherOptions as p, LoggingFunction as pt, EmittedPrebuiltChunk as q, RenderedChunk as qt, defineConfig as r, ModuleTypeFilter as rt, ExternalOptionFunction as s, RolldownFsModule as st, ConfigExport as t, GeneralHookFilter as tt, ModuleTypes as u, NormalizedInputOptions as ut, ImportKind as v, RolldownWatcherEvent as vt, PartialResolvedId as w, build as wt, ModuleType as x, rolldown as xt, LoadResult as y, RolldownWatcherWatcherEventMap as yt, ExistingRawSourceMap as z, ModuleFormat as zt };
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { Module } from "node:module";
|
|
2
|
+
import { MessageChannel } from "node:worker_threads";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
//#region ../../node_modules/.pnpm/fresh-import@0.2.1/node_modules/fresh-import/dist/index.js
|
|
5
|
+
const instanceId = Math.random().toString(36).slice(2);
|
|
6
|
+
const relativeImportRE = /^\.{1,2}(?:\/|\\)/;
|
|
7
|
+
function escapeRegExp(value) {
|
|
8
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The tracking query name `fresh-import-<instance>`, where `<instance>` is a
|
|
12
|
+
* random value unique to this loaded module instance. Any two instances (even
|
|
13
|
+
* two copies of the same build loaded into the same process) get distinct
|
|
14
|
+
* names, so each hook only recognizes the imports it tagged itself.
|
|
15
|
+
*/
|
|
16
|
+
function buildQueryName() {
|
|
17
|
+
return `fresh-import-${instanceId}`;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Build the regex that matches the tracking query `?<name>=<id>,<context>`
|
|
21
|
+
* (or the `&<name>=...` form).
|
|
22
|
+
*/
|
|
23
|
+
function buildQueryRE(queryName) {
|
|
24
|
+
return new RegExp(`(?:\\?|&)${escapeRegExp(queryName)}=(\\d+),([^&]+)(?:&|$)`);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Build the tracking query `?<name>=<id>,<context>` that `collect` appends to
|
|
28
|
+
* the entry specifier. `id` cache-busts the import (a distinct URL forces a
|
|
29
|
+
* fresh evaluation) and `context` tags the import graph so the resolve hook can
|
|
30
|
+
* attribute resolved dependencies back to the originating collect.
|
|
31
|
+
*/
|
|
32
|
+
function formatTrackingQuery(queryName, id, context) {
|
|
33
|
+
return `?${queryName}=${id},${context}`;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Shared body of the resolve hook for both the on-thread and off-thread
|
|
37
|
+
* importers. Given an already-resolved `result`, decides whether it is a tracked
|
|
38
|
+
* relative file dependency; if so, reports it via `onDependency` and tags the
|
|
39
|
+
* URL so the query propagates to its own dependencies.
|
|
40
|
+
*
|
|
41
|
+
* The sync/async difference between the two hooks lives entirely in the caller
|
|
42
|
+
* (which awaits `nextResolve` or not); this function performs no I/O. `result`
|
|
43
|
+
* is mutated in place and returned.
|
|
44
|
+
*/
|
|
45
|
+
function trackResolved(specifier, context, result, queryName, queryRE, onDependency) {
|
|
46
|
+
const isRelativeImport = relativeImportRE.test(specifier);
|
|
47
|
+
if (result.format === "builtin" || !isRelativeImport) return result;
|
|
48
|
+
if (!context.parentURL || queryRE.test(result.url) || !result.url.startsWith("file:")) return result;
|
|
49
|
+
const m = queryRE.exec(context.parentURL);
|
|
50
|
+
if (m) {
|
|
51
|
+
const [, id, contextFile] = m;
|
|
52
|
+
onDependency(contextFile, result.url);
|
|
53
|
+
result.url = result.url.replace(/(\?)|$/, (_n, n1) => `?${queryName}=${id},${contextFile}${n1 === "?" ? "&" : ""}`);
|
|
54
|
+
}
|
|
55
|
+
return result;
|
|
56
|
+
}
|
|
57
|
+
var loader_default = "data:text/javascript,Math.random().toString(36).slice(2);%0Aconst relativeImportRE = /^\\.{1,2}(%3F:\\/|\\\\)/;%0Afunction escapeRegExp(value) {%0A%09return value.replace(/[.*+%3F^${}()|[\\]\\\\]/g, \"\\\\$&\");%0A}%0A/**%0A* Build the regex that matches the tracking query `%3F<name>=<id>,<context>`%0A* (or the `&<name>=...` form).%0A*/%0Afunction buildQueryRE(queryName) {%0A%09return new RegExp(`(%3F:\\\\%3F|&)${escapeRegExp(queryName)}=(\\\\d+),([^&]+)(%3F:&|$)`);%0A}%0A/**%0A* Shared body of the resolve hook for both the on-thread and off-thread%0A* importers. Given an already-resolved `result`, decides whether it is a tracked%0A* relative file dependency; if so, reports it via `onDependency` and tags the%0A* URL so the query propagates to its own dependencies.%0A*%0A* The sync/async difference between the two hooks lives entirely in the caller%0A* (which awaits `nextResolve` or not); this function performs no I/O. `result`%0A* is mutated in place and returned.%0A*/%0Afunction trackResolved(specifier, context, result, queryName, queryRE, onDependency) {%0A%09const isRelativeImport = relativeImportRE.test(specifier);%0A%09if (result.format === \"builtin\" || !isRelativeImport) return result;%0A%09if (!context.parentURL || queryRE.test(result.url) || !result.url.startsWith(\"file:\")) return result;%0A%09const m = queryRE.exec(context.parentURL);%0A%09if (m) {%0A%09%09const [, id, contextFile] = m;%0A%09%09onDependency(contextFile, result.url);%0A%09%09result.url = result.url.replace(/(\\%3F)|$/, (_n, n1) => `%3F${queryName}=${id},${contextFile}${n1 === \"%3F\" %3F \"&\" : \"\"}`);%0A%09}%0A%09return result;%0A}%0A//%23endregion%0A//%23region src/off-thread/loader.ts%0Alet port;%0Alet queryName;%0Alet queryRE;%0Aconst initialize = async (data) => {%0A%09port = data.port;%0A%09queryName = data.queryName;%0A%09queryRE = buildQueryRE(queryName);%0A};%0Aconst resolve = async (specifier, context, nextResolve) => {%0A%09return trackResolved(specifier, context, await nextResolve(specifier, context), queryName, queryRE, (ctx, url) => {%0A%09%09port.postMessage({%0A%09%09%09context: ctx,%0A%09%09%09url%0A%09%09});%0A%09});%0A};%0A//%23endregion%0Aexport { initialize, resolve };%0A";
|
|
58
|
+
let nextId$1 = 0;
|
|
59
|
+
/**
|
|
60
|
+
* Off-thread importer: registers an ESM loader in a worker thread via
|
|
61
|
+
* `Module.register` and receives tracked dependencies over a `MessagePort`.
|
|
62
|
+
* Used on Node versions without `Module.registerHooks`.
|
|
63
|
+
*/
|
|
64
|
+
function createOffThreadImporter() {
|
|
65
|
+
const queryName = buildQueryName();
|
|
66
|
+
const { port1, port2 } = new MessageChannel();
|
|
67
|
+
Module.register(loader_default, {
|
|
68
|
+
data: {
|
|
69
|
+
port: port2,
|
|
70
|
+
queryName
|
|
71
|
+
},
|
|
72
|
+
transferList: [port2]
|
|
73
|
+
});
|
|
74
|
+
port1.unref();
|
|
75
|
+
return { async collect(specifier) {
|
|
76
|
+
const id = nextId$1++;
|
|
77
|
+
const depsList = /* @__PURE__ */ new Set();
|
|
78
|
+
const onMessage = (e) => {
|
|
79
|
+
if (e.context === specifier) depsList.add(e.url);
|
|
80
|
+
};
|
|
81
|
+
port1.on("message", onMessage);
|
|
82
|
+
port1.unref();
|
|
83
|
+
try {
|
|
84
|
+
const result = await import(specifier + formatTrackingQuery(queryName, id, specifier));
|
|
85
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
86
|
+
return {
|
|
87
|
+
result,
|
|
88
|
+
dependencies: [...depsList].filter((url) => url.startsWith("file:")).map((url) => fileURLToPath(url))
|
|
89
|
+
};
|
|
90
|
+
} finally {
|
|
91
|
+
port1.off("message", onMessage);
|
|
92
|
+
}
|
|
93
|
+
} };
|
|
94
|
+
}
|
|
95
|
+
let nextId = 0;
|
|
96
|
+
/**
|
|
97
|
+
* On-thread importer: registers synchronous resolution hooks via
|
|
98
|
+
* `Module.registerHooks` (Node 22.15+/23.5+).
|
|
99
|
+
*/
|
|
100
|
+
function createOnThreadImporter() {
|
|
101
|
+
const registry = /* @__PURE__ */ new Map();
|
|
102
|
+
const queryName = buildQueryName();
|
|
103
|
+
const queryRE = buildQueryRE(queryName);
|
|
104
|
+
const resolve = (specifier, context, nextResolve) => {
|
|
105
|
+
return trackResolved(specifier, context, nextResolve(specifier, context), queryName, queryRE, (ctx, url) => {
|
|
106
|
+
registry.get(ctx)?.add(url);
|
|
107
|
+
});
|
|
108
|
+
};
|
|
109
|
+
Module.registerHooks({ resolve });
|
|
110
|
+
return { async collect(specifier) {
|
|
111
|
+
const id = nextId++;
|
|
112
|
+
const depsList = /* @__PURE__ */ new Set();
|
|
113
|
+
registry.set(specifier, depsList);
|
|
114
|
+
try {
|
|
115
|
+
return {
|
|
116
|
+
result: await import(specifier + formatTrackingQuery(queryName, id, specifier)),
|
|
117
|
+
dependencies: [...depsList].filter((url) => url.startsWith("file:")).map((url) => fileURLToPath(url))
|
|
118
|
+
};
|
|
119
|
+
} finally {
|
|
120
|
+
registry.delete(specifier);
|
|
121
|
+
}
|
|
122
|
+
} };
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Create the importer best suited to the current runtime, or `undefined` if it
|
|
126
|
+
* provides neither module-hook API.
|
|
127
|
+
*/
|
|
128
|
+
function createImporter() {
|
|
129
|
+
if (Module.registerHooks) return createOnThreadImporter();
|
|
130
|
+
if (Module.register) return createOffThreadImporter();
|
|
131
|
+
}
|
|
132
|
+
let importer;
|
|
133
|
+
let initialized = false;
|
|
134
|
+
/**
|
|
135
|
+
* Import an ESM entry in its own fresh module graph (separate from Node's module
|
|
136
|
+
* cache and from other concurrent imports) and report the dependency files it
|
|
137
|
+
* pulled in.
|
|
138
|
+
*
|
|
139
|
+
* Each call re-evaluates the entry in a fresh graph; concurrent calls stay
|
|
140
|
+
* isolated from one another. Only statically-imported relative dependencies are
|
|
141
|
+
* tracked, not dynamic imports.
|
|
142
|
+
*
|
|
143
|
+
* Returns `undefined` on runtimes that provide neither `Module.registerHooks`
|
|
144
|
+
* nor `Module.register`.
|
|
145
|
+
*/
|
|
146
|
+
function freshImport(specifier) {
|
|
147
|
+
if (!initialized) {
|
|
148
|
+
importer = createImporter();
|
|
149
|
+
initialized = true;
|
|
150
|
+
}
|
|
151
|
+
return importer?.collect(specifier);
|
|
152
|
+
}
|
|
153
|
+
//#endregion
|
|
154
|
+
export { freshImport };
|
|
@@ -13,8 +13,8 @@ type GetLogFilter = (filters: string[]) => (log: RolldownLog) => boolean;
|
|
|
13
13
|
*
|
|
14
14
|
* @example
|
|
15
15
|
* ```ts
|
|
16
|
-
* import { defineConfig } from 'rolldown';
|
|
17
|
-
* import { getLogFilter } from 'rolldown/getLogFilter';
|
|
16
|
+
* import { defineConfig } from '@rollipop/rolldown';
|
|
17
|
+
* import { getLogFilter } from '@rollipop/rolldown/getLogFilter';
|
|
18
18
|
*
|
|
19
19
|
* const logFilter = getLogFilter(['code:FOO', 'code:BAR']);
|
|
20
20
|
*
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as rolldown } from "./rolldown-
|
|
1
|
+
import { t as rolldown } from "./rolldown-BCi17Yn9.mjs";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import { readdir } from "node:fs/promises";
|
|
@@ -98,21 +98,38 @@ function tryStatSync(file) {
|
|
|
98
98
|
return fs.statSync(file, { throwIfNoEntry: false });
|
|
99
99
|
} catch {}
|
|
100
100
|
}
|
|
101
|
+
async function loadNativeConfig(resolvedPath) {
|
|
102
|
+
const url = pathToFileURL(resolvedPath).href;
|
|
103
|
+
const { freshImport } = await import("./dist-DKbukT1H.mjs");
|
|
104
|
+
const freshImported = freshImport(url);
|
|
105
|
+
if (freshImported) {
|
|
106
|
+
const { result } = await freshImported;
|
|
107
|
+
return result.default;
|
|
108
|
+
}
|
|
109
|
+
return (await import(url + "?t=" + Date.now())).default;
|
|
110
|
+
}
|
|
101
111
|
/**
|
|
102
112
|
* Load config from a file in a way that Rolldown does.
|
|
103
113
|
*
|
|
104
114
|
* @param configPath The path to the config file. If empty, it will look for `rolldown.config` with supported extensions in the current working directory.
|
|
115
|
+
* @param options Loading options. `configLoader` selects `'bundle'` (default) or `'native'`.
|
|
105
116
|
* @returns The loaded config export
|
|
106
117
|
*
|
|
107
118
|
* @category Config
|
|
108
119
|
*/
|
|
109
|
-
async function loadConfig(configPath) {
|
|
120
|
+
async function loadConfig(configPath, options = {}) {
|
|
121
|
+
const configLoader = options.configLoader ?? "bundle";
|
|
110
122
|
const ext = path.extname(configPath = configPath || await findConfigFileNameInCwd());
|
|
111
123
|
try {
|
|
124
|
+
if (configLoader === "native") return await loadNativeConfig(path.resolve(configPath));
|
|
112
125
|
if (SUPPORTED_JS_CONFIG_FORMATS.includes(ext) || process.env.NODE_OPTIONS?.includes("--import=tsx") && SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return (await import(pathToFileURL(configPath).href)).default;
|
|
113
126
|
else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) return await loadTsConfig(path.resolve(configPath));
|
|
114
127
|
else throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(",")}\` but got \`${ext}\``);
|
|
115
128
|
} catch (err) {
|
|
129
|
+
if (configLoader === "native") {
|
|
130
|
+
const tsHint = SUPPORTED_TS_CONFIG_FORMATS.includes(ext) && !process.features.typescript ? " This runtime does not natively support TypeScript config files." : "";
|
|
131
|
+
throw new Error(`Failed to load the config file "${configPath}" using the "native" config loader.${tsHint} Try "--configLoader bundle", or register a loader such as "--import tsx".`, { cause: err });
|
|
132
|
+
}
|
|
116
133
|
throw new Error("Error happened while loading config.", { cause: err });
|
|
117
134
|
}
|
|
118
135
|
}
|
|
@@ -97,7 +97,12 @@ function locate(source, search, options) {
|
|
|
97
97
|
}
|
|
98
98
|
//#endregion
|
|
99
99
|
//#region src/log/logs.ts
|
|
100
|
-
const INVALID_LOG_POSITION = "INVALID_LOG_POSITION"
|
|
100
|
+
const INVALID_LOG_POSITION = "INVALID_LOG_POSITION";
|
|
101
|
+
const PLUGIN_ERROR = "PLUGIN_ERROR";
|
|
102
|
+
const INPUT_HOOK_IN_OUTPUT_PLUGIN = "INPUT_HOOK_IN_OUTPUT_PLUGIN";
|
|
103
|
+
const CYCLE_LOADING = "CYCLE_LOADING";
|
|
104
|
+
const MULTIPLE_WATCHER_OPTION = "MULTIPLE_WATCHER_OPTION";
|
|
105
|
+
const PARSE_ERROR = "PARSE_ERROR";
|
|
101
106
|
function logParseError(message, id, pos) {
|
|
102
107
|
return {
|
|
103
108
|
code: PARSE_ERROR,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as __toESM, t as require_binding } from "./binding-
|
|
2
|
-
import { c as logPluginError, n as error } from "./logs-
|
|
1
|
+
import { n as __toESM, t as require_binding } from "./binding-9kL0gFYL.mjs";
|
|
2
|
+
import { c as logPluginError, n as error } from "./logs-ZGEh6uhb.mjs";
|
|
3
3
|
//#region src/builtin-plugin/utils.ts
|
|
4
4
|
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
|
|
5
5
|
var BuiltinPlugin = class {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { n as __toESM, t as require_binding } from "./binding-
|
|
2
|
-
//#region ../../node_modules/.pnpm/oxc-parser@0.
|
|
1
|
+
import { n as __toESM, t as require_binding } from "./binding-9kL0gFYL.mjs";
|
|
2
|
+
//#region ../../node_modules/.pnpm/oxc-parser@0.139.0/node_modules/oxc-parser/src-js/wrap.js
|
|
3
3
|
var import_binding = /* @__PURE__ */ __toESM(require_binding(), 1);
|
|
4
4
|
function wrap(result) {
|
|
5
5
|
let program, module, comments, errors;
|