rolldown 1.0.0-beta.2-commit.2666b23 → 1.0.0-beta.20
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/bin/cli.mjs +2 -0
- package/dist/{cjs/cli.cjs → cli.cjs} +630 -603
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/{esm/cli.mjs → cli.mjs} +605 -575
- package/dist/config.cjs +12 -0
- package/dist/config.d.cts +10 -0
- package/dist/config.d.mts +10 -0
- package/dist/config.mjs +10 -0
- package/dist/experimental-index.cjs +107 -0
- package/dist/experimental-index.d.cts +63 -0
- package/dist/experimental-index.d.mts +63 -0
- package/dist/experimental-index.mjs +82 -0
- package/dist/experimental-runtime-types.d.ts +52 -0
- package/dist/filter-index.cjs +105 -0
- package/dist/filter-index.d.cts +4 -0
- package/dist/filter-index.d.mts +4 -0
- package/dist/filter-index.mjs +44 -0
- package/dist/index.cjs +9 -0
- package/dist/index.d.cts +3 -0
- package/dist/index.d.mts +3 -0
- package/dist/index.mjs +5 -0
- package/dist/{cjs/parallel-plugin-worker.cjs → parallel-plugin-worker.cjs} +6 -14
- package/dist/parallel-plugin-worker.d.cts +1 -0
- package/dist/parallel-plugin-worker.d.mts +1 -0
- package/dist/{esm/parallel-plugin-worker.mjs → parallel-plugin-worker.mjs} +5 -12
- package/dist/{cjs/parallel-plugin.cjs → parallel-plugin.cjs} +1 -2
- package/dist/parallel-plugin.d.cts +14 -0
- package/dist/parallel-plugin.d.mts +14 -0
- package/dist/{esm/parallel-plugin.mjs → parallel-plugin.mjs} +0 -1
- package/dist/parse-ast-index.cjs +4 -0
- package/dist/parse-ast-index.d.cts +9 -0
- package/dist/parse-ast-index.d.mts +9 -0
- package/dist/parse-ast-index.mjs +3 -0
- package/dist/shared/binding-5O9lFYtz.d.mts +1215 -0
- package/dist/shared/binding-BvKFOCZr.d.cts +1215 -0
- package/dist/shared/{chunk-qZFfknuJ.cjs → chunk-DDkG_k5U.cjs} +0 -1
- package/dist/shared/define-config-BOD4oRSZ.d.cts +1204 -0
- package/dist/shared/define-config-DdVYel_V.d.mts +1204 -0
- package/dist/shared/load-config-B_hPIyxu.mjs +119 -0
- package/dist/shared/load-config-BdY850xq.cjs +125 -0
- package/dist/shared/misc-BKp5iIef.cjs +67 -0
- package/dist/shared/misc-BN0nse6C.mjs +25 -0
- package/dist/shared/parse-ast-index-CVVmsBjK.cjs +738 -0
- package/dist/shared/parse-ast-index-DW8kbzjr.mjs +616 -0
- package/dist/shared/{prompt-Nfm4Xz36.mjs → prompt-C5jz26Zn.mjs} +247 -246
- package/dist/shared/{prompt-B7tq3GL9.cjs → prompt-QNI93ne7.cjs} +250 -250
- package/dist/shared/src-CZ0tgOug.cjs +4851 -0
- package/dist/shared/src-DHXNdTPA.mjs +4647 -0
- package/package.json +63 -67
- package/bin/cli.js +0 -2
- package/dist/cjs/experimental-index.cjs +0 -79
- package/dist/cjs/index.cjs +0 -8
- package/dist/cjs/parse-ast-index.cjs +0 -57
- package/dist/esm/experimental-index.mjs +0 -56
- package/dist/esm/index.mjs +0 -4
- package/dist/esm/parse-ast-index.mjs +0 -55
- package/dist/shared/binding-l7VLSKnB.mjs +0 -610
- package/dist/shared/binding-orkvONpS.cjs +0 -661
- package/dist/shared/src-BC6S-BmL.cjs +0 -2828
- package/dist/shared/src-mupmacNC.mjs +0 -2647
- package/dist/types/api/build.d.ts +0 -18
- package/dist/types/api/build.js +0 -22
- package/dist/types/api/experimental.d.ts +0 -7
- package/dist/types/api/experimental.js +0 -13
- package/dist/types/api/rolldown/index.d.ts +0 -3
- package/dist/types/api/rolldown/index.js +0 -7
- package/dist/types/api/rolldown/rolldown-build.d.ts +0 -12
- package/dist/types/api/rolldown/rolldown-build.js +0 -43
- package/dist/types/api/watch/index.d.ts +0 -3
- package/dist/types/api/watch/index.js +0 -8
- package/dist/types/api/watch/watch-emitter.d.ts +0 -31
- package/dist/types/api/watch/watch-emitter.js +0 -69
- package/dist/types/api/watch/watcher.d.ts +0 -13
- package/dist/types/api/watch/watcher.js +0 -66
- package/dist/types/binding.d.ts +0 -1327
- package/dist/types/builtin-plugin/alias-plugin.d.ts +0 -10
- package/dist/types/builtin-plugin/alias-plugin.js +0 -4
- package/dist/types/builtin-plugin/constructors.d.ts +0 -20
- package/dist/types/builtin-plugin/constructors.js +0 -68
- package/dist/types/builtin-plugin/replace-plugin.d.ts +0 -28
- package/dist/types/builtin-plugin/replace-plugin.js +0 -29
- package/dist/types/builtin-plugin/transform-plugin.d.ts +0 -9
- package/dist/types/builtin-plugin/transform-plugin.js +0 -16
- package/dist/types/builtin-plugin/utils.d.ts +0 -8
- package/dist/types/builtin-plugin/utils.js +0 -19
- package/dist/types/cli/arguments/alias.d.ts +0 -16
- package/dist/types/cli/arguments/alias.js +0 -63
- package/dist/types/cli/arguments/index.d.ts +0 -15
- package/dist/types/cli/arguments/index.js +0 -127
- package/dist/types/cli/arguments/normalize.d.ts +0 -12
- package/dist/types/cli/arguments/normalize.js +0 -48
- package/dist/types/cli/arguments/utils.d.ts +0 -8
- package/dist/types/cli/arguments/utils.js +0 -67
- package/dist/types/cli/colors.d.ts +0 -11
- package/dist/types/cli/colors.js +0 -17
- package/dist/types/cli/commands/bundle.d.ts +0 -3
- package/dist/types/cli/commands/bundle.js +0 -203
- package/dist/types/cli/commands/help.d.ts +0 -1
- package/dist/types/cli/commands/help.js +0 -88
- package/dist/types/cli/index.d.ts +0 -1
- package/dist/types/cli/index.js +0 -27
- package/dist/types/cli/load-config.d.ts +0 -3
- package/dist/types/cli/load-config.js +0 -95
- package/dist/types/cli/logger.d.ts +0 -5
- package/dist/types/cli/logger.js +0 -35
- package/dist/types/constants/plugin-context.d.ts +0 -7
- package/dist/types/constants/plugin-context.js +0 -7
- package/dist/types/constants/plugin.d.ts +0 -45
- package/dist/types/constants/plugin.js +0 -69
- package/dist/types/experimental-index.d.ts +0 -9
- package/dist/types/experimental-index.js +0 -9
- package/dist/types/index.d.ts +0 -28
- package/dist/types/index.js +0 -7
- package/dist/types/log/logHandler.d.ts +0 -4
- package/dist/types/log/logHandler.js +0 -25
- package/dist/types/log/logger.d.ts +0 -6
- package/dist/types/log/logger.js +0 -107
- package/dist/types/log/logging.d.ts +0 -11
- package/dist/types/log/logging.js +0 -11
- package/dist/types/log/logs.d.ts +0 -18
- package/dist/types/log/logs.js +0 -86
- package/dist/types/options/input-options.d.ts +0 -170
- package/dist/types/options/input-options.js +0 -1
- package/dist/types/options/normalized-input-options.d.ts +0 -18
- package/dist/types/options/normalized-input-options.js +0 -21
- package/dist/types/options/normalized-output-options.d.ts +0 -67
- package/dist/types/options/normalized-output-options.js +0 -99
- package/dist/types/options/output-options.d.ts +0 -86
- package/dist/types/options/output-options.js +0 -1
- package/dist/types/options/watch-options.d.ts +0 -5
- package/dist/types/options/watch-options.js +0 -1
- package/dist/types/parallel-plugin-worker.d.ts +0 -1
- package/dist/types/parallel-plugin-worker.js +0 -31
- package/dist/types/parallel-plugin.d.ts +0 -1
- package/dist/types/parallel-plugin.js +0 -1
- package/dist/types/parse-ast-index.d.ts +0 -4
- package/dist/types/parse-ast-index.js +0 -73
- package/dist/types/plugin/bindingify-build-hooks.d.ts +0 -10
- package/dist/types/plugin/bindingify-build-hooks.js +0 -213
- package/dist/types/plugin/bindingify-hook-filter.d.ts +0 -7
- package/dist/types/plugin/bindingify-hook-filter.js +0 -39
- package/dist/types/plugin/bindingify-output-hooks.d.ts +0 -14
- package/dist/types/plugin/bindingify-output-hooks.js +0 -189
- package/dist/types/plugin/bindingify-plugin-hook-meta.d.ts +0 -8
- package/dist/types/plugin/bindingify-plugin-hook-meta.js +0 -19
- package/dist/types/plugin/bindingify-plugin.d.ts +0 -15
- package/dist/types/plugin/bindingify-plugin.js +0 -124
- package/dist/types/plugin/bindingify-watch-hooks.d.ts +0 -5
- package/dist/types/plugin/bindingify-watch-hooks.js +0 -29
- package/dist/types/plugin/hook-filter.d.ts +0 -48
- package/dist/types/plugin/hook-filter.js +0 -1
- package/dist/types/plugin/index.d.ts +0 -126
- package/dist/types/plugin/index.js +0 -1
- package/dist/types/plugin/minimal-plugin-context.d.ts +0 -15
- package/dist/types/plugin/minimal-plugin-context.js +0 -25
- package/dist/types/plugin/parallel-plugin-implementation.d.ts +0 -10
- package/dist/types/plugin/parallel-plugin-implementation.js +0 -3
- package/dist/types/plugin/parallel-plugin.d.ts +0 -9
- package/dist/types/plugin/parallel-plugin.js +0 -6
- package/dist/types/plugin/plugin-context-data.d.ts +0 -16
- package/dist/types/plugin/plugin-context-data.js +0 -55
- package/dist/types/plugin/plugin-context.d.ts +0 -52
- package/dist/types/plugin/plugin-context.js +0 -108
- package/dist/types/plugin/plugin-driver.d.ts +0 -8
- package/dist/types/plugin/plugin-driver.js +0 -88
- package/dist/types/plugin/transform-plugin-context.d.ts +0 -17
- package/dist/types/plugin/transform-plugin-context.js +0 -37
- package/dist/types/types/assert.d.ts +0 -13
- package/dist/types/types/assert.js +0 -1
- package/dist/types/types/config-export.d.ts +0 -5
- package/dist/types/types/config-export.js +0 -1
- package/dist/types/types/misc.d.ts +0 -40
- package/dist/types/types/misc.js +0 -1
- package/dist/types/types/module-info.d.ts +0 -15
- package/dist/types/types/module-info.js +0 -1
- package/dist/types/types/module-side-effects.d.ts +0 -10
- package/dist/types/types/module-side-effects.js +0 -1
- package/dist/types/types/output-bundle.d.ts +0 -4
- package/dist/types/types/output-bundle.js +0 -1
- package/dist/types/types/rolldown-options.d.ts +0 -5
- package/dist/types/types/rolldown-options.js +0 -1
- package/dist/types/types/rolldown-output.d.ts +0 -63
- package/dist/types/types/rolldown-output.js +0 -1
- package/dist/types/types/schema.d.ts +0 -33
- package/dist/types/types/schema.js +0 -1
- package/dist/types/types/sourcemap.d.ts +0 -13
- package/dist/types/types/sourcemap.js +0 -16
- package/dist/types/types/utils.d.ts +0 -13
- package/dist/types/types/utils.js +0 -1
- package/dist/types/utils/asset-source.d.ts +0 -4
- package/dist/types/utils/asset-source.js +0 -8
- package/dist/types/utils/async-flatten.d.ts +0 -1
- package/dist/types/utils/async-flatten.js +0 -7
- package/dist/types/utils/bindingify-input-options.d.ts +0 -7
- package/dist/types/utils/bindingify-input-options.js +0 -225
- package/dist/types/utils/bindingify-output-options.d.ts +0 -3
- package/dist/types/utils/bindingify-output-options.js +0 -92
- package/dist/types/utils/code-frame.d.ts +0 -1
- package/dist/types/utils/code-frame.js +0 -46
- package/dist/types/utils/compose-js-plugins.d.ts +0 -2
- package/dist/types/utils/compose-js-plugins.js +0 -400
- package/dist/types/utils/create-bundler-option.d.ts +0 -11
- package/dist/types/utils/create-bundler-option.js +0 -53
- package/dist/types/utils/create-bundler.d.ts +0 -8
- package/dist/types/utils/create-bundler.js +0 -15
- package/dist/types/utils/define-config.d.ts +0 -5
- package/dist/types/utils/define-config.js +0 -3
- package/dist/types/utils/error.d.ts +0 -2
- package/dist/types/utils/error.js +0 -65
- package/dist/types/utils/initialize-parallel-plugins.d.ts +0 -19
- package/dist/types/utils/initialize-parallel-plugins.js +0 -54
- package/dist/types/utils/misc.d.ts +0 -6
- package/dist/types/utils/misc.js +0 -22
- package/dist/types/utils/normalize-hook.d.ts +0 -7
- package/dist/types/utils/normalize-hook.js +0 -21
- package/dist/types/utils/normalize-plugin-option.d.ts +0 -13
- package/dist/types/utils/normalize-plugin-option.js +0 -35
- package/dist/types/utils/normalize-string-or-regex.d.ts +0 -2
- package/dist/types/utils/normalize-string-or-regex.js +0 -14
- package/dist/types/utils/plugin/index.d.ts +0 -2
- package/dist/types/utils/plugin/index.js +0 -7
- package/dist/types/utils/transform-module-info.d.ts +0 -4
- package/dist/types/utils/transform-module-info.js +0 -19
- package/dist/types/utils/transform-rendered-chunk.d.ts +0 -4
- package/dist/types/utils/transform-rendered-chunk.js +0 -43
- package/dist/types/utils/transform-rendered-module.d.ts +0 -3
- package/dist/types/utils/transform-rendered-module.js +0 -10
- package/dist/types/utils/transform-side-effects.d.ts +0 -3
- package/dist/types/utils/transform-side-effects.js +0 -16
- package/dist/types/utils/transform-sourcemap.d.ts +0 -3
- package/dist/types/utils/transform-sourcemap.js +0 -29
- package/dist/types/utils/transform-to-rollup-output.d.ts +0 -11
- package/dist/types/utils/transform-to-rollup-output.js +0 -165
- package/dist/types/utils/validator.d.ts +0 -7
- package/dist/types/utils/validator.js +0 -275
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import type { StringOrRegExp } from '../types/utils';
|
|
2
|
-
import type { PreRenderedChunk } from '../binding';
|
|
3
|
-
import { SourcemapIgnoreListOption, SourcemapPathTransformOption } from '../types/misc';
|
|
4
|
-
import { RolldownOutputPluginOption } from '../plugin';
|
|
5
|
-
import { RenderedChunk } from '../types/rolldown-output';
|
|
6
|
-
export type ModuleFormat = 'es' | 'cjs' | 'esm' | 'module' | 'commonjs' | 'iife' | 'umd' | 'experimental-app';
|
|
7
|
-
export type AddonFunction = (chunk: RenderedChunk) => string | Promise<string>;
|
|
8
|
-
export type ChunkFileNamesFunction = (chunkInfo: PreRenderedChunk) => string;
|
|
9
|
-
export type GlobalsFunction = (name: string) => string;
|
|
10
|
-
export type ESTarget = 'es6' | 'es2015' | 'es2016' | 'es2017' | 'es2018' | 'es2019' | 'es2020' | 'es2021' | 'es2022' | 'es2023' | 'es2024' | 'esnext';
|
|
11
|
-
export interface OutputOptions {
|
|
12
|
-
dir?: string;
|
|
13
|
-
file?: string;
|
|
14
|
-
exports?: 'auto' | 'named' | 'default' | 'none';
|
|
15
|
-
hashCharacters?: 'base64' | 'base36' | 'hex';
|
|
16
|
-
/**
|
|
17
|
-
* Expected format of generated code.
|
|
18
|
-
* - `'es'`, `'esm'` and `'module'` are the same format, all stand for ES module.
|
|
19
|
-
* - `'cjs'` and `'commonjs'` are the same format, all stand for CommonJS module.
|
|
20
|
-
* - `'iife'` stands for [Immediately Invoked Function Expression](https://developer.mozilla.org/en-US/docs/Glossary/IIFE).
|
|
21
|
-
* - `'umd'` stands for [Universal Module Definition](https://github.com/umdjs/umd).
|
|
22
|
-
*
|
|
23
|
-
* @default 'esm'
|
|
24
|
-
*/
|
|
25
|
-
format?: ModuleFormat;
|
|
26
|
-
sourcemap?: boolean | 'inline' | 'hidden';
|
|
27
|
-
sourcemapIgnoreList?: boolean | SourcemapIgnoreListOption;
|
|
28
|
-
sourcemapPathTransform?: SourcemapPathTransformOption;
|
|
29
|
-
banner?: string | AddonFunction;
|
|
30
|
-
footer?: string | AddonFunction;
|
|
31
|
-
intro?: string | AddonFunction;
|
|
32
|
-
outro?: string | AddonFunction;
|
|
33
|
-
extend?: boolean;
|
|
34
|
-
esModule?: boolean | 'if-default-prop';
|
|
35
|
-
assetFileNames?: string;
|
|
36
|
-
entryFileNames?: string | ChunkFileNamesFunction;
|
|
37
|
-
chunkFileNames?: string | ChunkFileNamesFunction;
|
|
38
|
-
cssEntryFileNames?: string | ChunkFileNamesFunction;
|
|
39
|
-
cssChunkFileNames?: string | ChunkFileNamesFunction;
|
|
40
|
-
minify?: boolean;
|
|
41
|
-
name?: string;
|
|
42
|
-
globals?: Record<string, string> | GlobalsFunction;
|
|
43
|
-
externalLiveBindings?: boolean;
|
|
44
|
-
inlineDynamicImports?: boolean;
|
|
45
|
-
advancedChunks?: {
|
|
46
|
-
minSize?: number;
|
|
47
|
-
maxSize?: number;
|
|
48
|
-
maxModuleSize?: number;
|
|
49
|
-
minModuleSize?: number;
|
|
50
|
-
minShareCount?: number;
|
|
51
|
-
groups?: {
|
|
52
|
-
name: string;
|
|
53
|
-
test?: StringOrRegExp;
|
|
54
|
-
priority?: number;
|
|
55
|
-
minSize?: number;
|
|
56
|
-
minShareCount?: number;
|
|
57
|
-
maxSize?: number;
|
|
58
|
-
maxModuleSize?: number;
|
|
59
|
-
minModuleSize?: number;
|
|
60
|
-
}[];
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Control comments in the output.
|
|
64
|
-
*
|
|
65
|
-
* - `none`: no comments
|
|
66
|
-
* - `preserve-legal`: preserve comments that contain `@license`, `@preserve` or starts with `//!` `/*!`
|
|
67
|
-
*/
|
|
68
|
-
comments?: 'none' | 'preserve-legal';
|
|
69
|
-
plugins?: RolldownOutputPluginOption;
|
|
70
|
-
polyfillRequire?: boolean;
|
|
71
|
-
target?: ESTarget;
|
|
72
|
-
}
|
|
73
|
-
interface OverwriteOutputOptionsForCli {
|
|
74
|
-
banner?: string;
|
|
75
|
-
footer?: string;
|
|
76
|
-
intro?: string;
|
|
77
|
-
outro?: string;
|
|
78
|
-
esModule?: boolean;
|
|
79
|
-
globals?: Record<string, string>;
|
|
80
|
-
advancedChunks?: {
|
|
81
|
-
minSize?: number;
|
|
82
|
-
minShareCount?: number;
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
export type OutputCliOptions = Omit<OutputOptions, keyof OverwriteOutputOptionsForCli | 'sourcemapIgnoreList' | 'sourcemapPathTransform'> & OverwriteOutputOptionsForCli;
|
|
86
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { parentPort, workerData } from 'node:worker_threads';
|
|
2
|
-
import { registerPlugins } from './binding';
|
|
3
|
-
import { bindingifyPlugin } from './plugin/bindingify-plugin';
|
|
4
|
-
import { PluginContextData } from './plugin/plugin-context-data';
|
|
5
|
-
const { registryId, pluginInfos, threadNumber } = workerData;
|
|
6
|
-
(async () => {
|
|
7
|
-
try {
|
|
8
|
-
const plugins = await Promise.all(pluginInfos.map(async (pluginInfo) => {
|
|
9
|
-
const pluginModule = await import(pluginInfo.fileUrl);
|
|
10
|
-
const definePluginImpl = pluginModule.default;
|
|
11
|
-
const plugin = await definePluginImpl(pluginInfo.options, {
|
|
12
|
-
threadNumber,
|
|
13
|
-
});
|
|
14
|
-
return {
|
|
15
|
-
index: pluginInfo.index,
|
|
16
|
-
// TODO(sapphi-red): support inputOptions and outputOptions
|
|
17
|
-
plugin: bindingifyPlugin(plugin, {}, {},
|
|
18
|
-
// TODO need to find a way to share pluginContextData
|
|
19
|
-
new PluginContextData(), () => { }, 'info'),
|
|
20
|
-
};
|
|
21
|
-
}));
|
|
22
|
-
registerPlugins(registryId, plugins);
|
|
23
|
-
parentPort.postMessage({ type: 'success' });
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
parentPort.postMessage({ type: 'error', error });
|
|
27
|
-
}
|
|
28
|
-
finally {
|
|
29
|
-
parentPort.unref();
|
|
30
|
-
}
|
|
31
|
-
})();
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { defineParallelPluginImplementation, type ParallelPluginImplementation, type Context, } from './plugin/parallel-plugin-implementation';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { defineParallelPluginImplementation, } from './plugin/parallel-plugin-implementation';
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import type { ParseResult, ParserOptions } from './binding';
|
|
2
|
-
export declare function parseAst(filename: string, sourceText: string, options?: ParserOptions | undefined | null): ParseResult;
|
|
3
|
-
export declare function parseAstAsync(filename: string, sourceText: string, options?: ParserOptions | undefined | null): Promise<ParseResult>;
|
|
4
|
-
export type { ParseResult, ParserOptions };
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { parseSync, parseAsync } from './binding';
|
|
2
|
-
import { locate } from './log/locate-character';
|
|
3
|
-
import { error, logParseError } from './log/logs';
|
|
4
|
-
import { getCodeFrame } from './utils/code-frame';
|
|
5
|
-
// The oxc program is a string in the result, we need to parse it to a object.
|
|
6
|
-
// Copy from https://github.com/oxc-project/oxc/blob/main/napi/parser/index.js#L12
|
|
7
|
-
function wrap(result, sourceText) {
|
|
8
|
-
let program, module, comments, errors, magicString;
|
|
9
|
-
return {
|
|
10
|
-
get program() {
|
|
11
|
-
if (!errors)
|
|
12
|
-
errors = result.errors;
|
|
13
|
-
if (errors.length > 0) {
|
|
14
|
-
return normalizeParseError(sourceText, errors);
|
|
15
|
-
}
|
|
16
|
-
// @ts-expect-error the result.program typing is `Program`
|
|
17
|
-
if (!program)
|
|
18
|
-
program = JSON.parse(result.program);
|
|
19
|
-
return program;
|
|
20
|
-
},
|
|
21
|
-
get module() {
|
|
22
|
-
if (!module)
|
|
23
|
-
module = result.module;
|
|
24
|
-
return module;
|
|
25
|
-
},
|
|
26
|
-
get comments() {
|
|
27
|
-
if (!comments)
|
|
28
|
-
comments = result.comments;
|
|
29
|
-
return comments;
|
|
30
|
-
},
|
|
31
|
-
get errors() {
|
|
32
|
-
if (!errors)
|
|
33
|
-
errors = result.errors;
|
|
34
|
-
return errors;
|
|
35
|
-
},
|
|
36
|
-
get magicString() {
|
|
37
|
-
if (!magicString)
|
|
38
|
-
magicString = result.magicString;
|
|
39
|
-
return magicString;
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
function normalizeParseError(sourceText, errors) {
|
|
44
|
-
let message = `Parse failed with ${errors.length} error${errors.length < 2 ? '' : 's'}:\n`;
|
|
45
|
-
for (let i = 0; i < errors.length; i++) {
|
|
46
|
-
if (i >= 5) {
|
|
47
|
-
message += '\n...';
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
const e = errors[i];
|
|
51
|
-
message +=
|
|
52
|
-
e.message +
|
|
53
|
-
'\n' +
|
|
54
|
-
e.labels
|
|
55
|
-
.map((label) => {
|
|
56
|
-
const location = locate(sourceText, label.start, { offsetLine: 1 });
|
|
57
|
-
if (!location) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
return getCodeFrame(sourceText, location.line, location.column);
|
|
61
|
-
})
|
|
62
|
-
.filter(Boolean)
|
|
63
|
-
.join('\n');
|
|
64
|
-
}
|
|
65
|
-
return error(logParseError(message));
|
|
66
|
-
}
|
|
67
|
-
// The api compat to rollup `parseAst` and `parseAstAsync`.
|
|
68
|
-
export function parseAst(filename, sourceText, options) {
|
|
69
|
-
return wrap(parseSync(filename, sourceText, options), sourceText);
|
|
70
|
-
}
|
|
71
|
-
export async function parseAstAsync(filename, sourceText, options) {
|
|
72
|
-
return wrap(await parseAsync(filename, sourceText, options), sourceText);
|
|
73
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { BindingGeneralHookFilter, BindingPluginOptions, BindingTransformHookFilter } from '../binding';
|
|
2
|
-
import { PluginHookWithBindingExt } from './bindingify-plugin-hook-meta';
|
|
3
|
-
import type { BindingifyPluginArgs } from './bindingify-plugin';
|
|
4
|
-
export declare function bindingifyBuildStart(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['buildStart']>;
|
|
5
|
-
export declare function bindingifyBuildEnd(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['buildEnd']>;
|
|
6
|
-
export declare function bindingifyResolveId(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['resolveId'], BindingGeneralHookFilter | undefined>;
|
|
7
|
-
export declare function bindingifyResolveDynamicImport(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['resolveDynamicImport']>;
|
|
8
|
-
export declare function bindingifyTransform(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['transform'], BindingTransformHookFilter | undefined>;
|
|
9
|
-
export declare function bindingifyLoad(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['load'], BindingGeneralHookFilter | undefined>;
|
|
10
|
-
export declare function bindingifyModuleParsed(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['moduleParsed']>;
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { normalizeHook } from '../utils/normalize-hook';
|
|
2
|
-
import { isEmptySourcemapFiled, normalizeTransformHookSourcemap, } from '../utils/transform-sourcemap';
|
|
3
|
-
import { transformModuleInfo } from '../utils/transform-module-info';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { bindingifySourcemap } from '../types/sourcemap';
|
|
6
|
-
import { PluginContext, } from './plugin-context';
|
|
7
|
-
import { TransformPluginContext } from './transform-plugin-context';
|
|
8
|
-
import { bindingifySideEffects } from '../utils/transform-side-effects';
|
|
9
|
-
import { bindingifyPluginHookMeta, } from './bindingify-plugin-hook-meta';
|
|
10
|
-
import { SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF } from '../constants/plugin-context';
|
|
11
|
-
import { bindingifyLoadFilter, bindingifyResolveIdFilter, bindingifyTransformFilter, } from './bindingify-hook-filter';
|
|
12
|
-
import { NormalizedInputOptionsImpl } from '../options/normalized-input-options';
|
|
13
|
-
import { normalizeErrors } from '../utils/error';
|
|
14
|
-
export function bindingifyBuildStart(args) {
|
|
15
|
-
const hook = args.plugin.buildStart;
|
|
16
|
-
if (!hook) {
|
|
17
|
-
return {};
|
|
18
|
-
}
|
|
19
|
-
const { handler, meta } = normalizeHook(hook);
|
|
20
|
-
return {
|
|
21
|
-
plugin: async (ctx, opts) => {
|
|
22
|
-
await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), new NormalizedInputOptionsImpl(opts, args.onLog));
|
|
23
|
-
},
|
|
24
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
25
|
-
};
|
|
26
|
-
}
|
|
27
|
-
export function bindingifyBuildEnd(args) {
|
|
28
|
-
const hook = args.plugin.buildEnd;
|
|
29
|
-
if (!hook) {
|
|
30
|
-
return {};
|
|
31
|
-
}
|
|
32
|
-
const { handler, meta } = normalizeHook(hook);
|
|
33
|
-
return {
|
|
34
|
-
plugin: async (ctx, err) => {
|
|
35
|
-
await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), err ? normalizeErrors(err) : undefined);
|
|
36
|
-
},
|
|
37
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
export function bindingifyResolveId(args) {
|
|
41
|
-
const hook = args.plugin.resolveId;
|
|
42
|
-
if (!hook) {
|
|
43
|
-
return {};
|
|
44
|
-
}
|
|
45
|
-
const { handler, meta, options } = normalizeHook(hook);
|
|
46
|
-
return {
|
|
47
|
-
plugin: async (ctx, specifier, importer, extraOptions) => {
|
|
48
|
-
const contextResolveOptions = extraOptions.custom != null
|
|
49
|
-
? args.pluginContextData.getSavedResolveOptions(extraOptions.custom)
|
|
50
|
-
: undefined;
|
|
51
|
-
const newExtraOptions = {
|
|
52
|
-
...extraOptions,
|
|
53
|
-
custom: contextResolveOptions?.custom,
|
|
54
|
-
[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF]: contextResolveOptions?.[SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF],
|
|
55
|
-
};
|
|
56
|
-
const ret = await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), specifier, importer ?? undefined, newExtraOptions);
|
|
57
|
-
if (ret == null) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
if (ret === false) {
|
|
61
|
-
return {
|
|
62
|
-
id: specifier,
|
|
63
|
-
external: true,
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
if (typeof ret === 'string') {
|
|
67
|
-
return {
|
|
68
|
-
id: ret,
|
|
69
|
-
};
|
|
70
|
-
}
|
|
71
|
-
args.pluginContextData.updateModuleOption(ret.id, {
|
|
72
|
-
meta: ret.meta || {},
|
|
73
|
-
moduleSideEffects: ret.moduleSideEffects || null,
|
|
74
|
-
});
|
|
75
|
-
return {
|
|
76
|
-
id: ret.id,
|
|
77
|
-
external: ret.external,
|
|
78
|
-
sideEffects: bindingifySideEffects(ret.moduleSideEffects),
|
|
79
|
-
};
|
|
80
|
-
},
|
|
81
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
82
|
-
filter: bindingifyResolveIdFilter(options.filter),
|
|
83
|
-
};
|
|
84
|
-
}
|
|
85
|
-
export function bindingifyResolveDynamicImport(args) {
|
|
86
|
-
const hook = args.plugin.resolveDynamicImport;
|
|
87
|
-
if (!hook) {
|
|
88
|
-
return {};
|
|
89
|
-
}
|
|
90
|
-
const { handler, meta } = normalizeHook(hook);
|
|
91
|
-
return {
|
|
92
|
-
plugin: async (ctx, specifier, importer) => {
|
|
93
|
-
const ret = await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), specifier, importer ?? undefined);
|
|
94
|
-
if (ret == null) {
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
if (ret === false) {
|
|
98
|
-
return {
|
|
99
|
-
id: specifier,
|
|
100
|
-
external: true,
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
if (typeof ret === 'string') {
|
|
104
|
-
return {
|
|
105
|
-
id: ret,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
const result = {
|
|
109
|
-
id: ret.id,
|
|
110
|
-
external: ret.external,
|
|
111
|
-
};
|
|
112
|
-
if (ret.moduleSideEffects !== null) {
|
|
113
|
-
result.sideEffects = bindingifySideEffects(ret.moduleSideEffects);
|
|
114
|
-
}
|
|
115
|
-
args.pluginContextData.updateModuleOption(ret.id, {
|
|
116
|
-
meta: ret.meta || {},
|
|
117
|
-
moduleSideEffects: ret.moduleSideEffects || null,
|
|
118
|
-
});
|
|
119
|
-
return result;
|
|
120
|
-
},
|
|
121
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
export function bindingifyTransform(args) {
|
|
125
|
-
const hook = args.plugin.transform;
|
|
126
|
-
if (!hook) {
|
|
127
|
-
return {};
|
|
128
|
-
}
|
|
129
|
-
const { handler, meta, options } = normalizeHook(hook);
|
|
130
|
-
return {
|
|
131
|
-
plugin: async (ctx, code, id, meta) => {
|
|
132
|
-
const ret = await handler.call(new TransformPluginContext(ctx.inner(), args.plugin, args.pluginContextData, ctx, id, code, args.onLog, args.logLevel), code, id, meta);
|
|
133
|
-
if (ret == null) {
|
|
134
|
-
return undefined;
|
|
135
|
-
}
|
|
136
|
-
if (typeof ret === 'string') {
|
|
137
|
-
return { code: ret };
|
|
138
|
-
}
|
|
139
|
-
args.pluginContextData.updateModuleOption(id, {
|
|
140
|
-
meta: ret.meta || {},
|
|
141
|
-
moduleSideEffects: ret.moduleSideEffects || null,
|
|
142
|
-
});
|
|
143
|
-
return {
|
|
144
|
-
code: ret.code,
|
|
145
|
-
map: bindingifySourcemap(normalizeTransformHookSourcemap(id, code, ret.map)),
|
|
146
|
-
sideEffects: bindingifySideEffects(ret.moduleSideEffects),
|
|
147
|
-
moduleType: ret.moduleType,
|
|
148
|
-
};
|
|
149
|
-
},
|
|
150
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
151
|
-
filter: bindingifyTransformFilter(options.filter),
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
export function bindingifyLoad(args) {
|
|
155
|
-
const hook = args.plugin.load;
|
|
156
|
-
if (!hook) {
|
|
157
|
-
return {};
|
|
158
|
-
}
|
|
159
|
-
const { handler, meta, options } = normalizeHook(hook);
|
|
160
|
-
return {
|
|
161
|
-
plugin: async (ctx, id) => {
|
|
162
|
-
const ret = await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel, id), id);
|
|
163
|
-
if (ret == null) {
|
|
164
|
-
return;
|
|
165
|
-
}
|
|
166
|
-
if (typeof ret === 'string') {
|
|
167
|
-
return { code: ret };
|
|
168
|
-
}
|
|
169
|
-
args.pluginContextData.updateModuleOption(id, {
|
|
170
|
-
meta: ret.meta || {},
|
|
171
|
-
moduleSideEffects: ret.moduleSideEffects || null,
|
|
172
|
-
});
|
|
173
|
-
let map = preProcessSourceMap(ret, id);
|
|
174
|
-
return {
|
|
175
|
-
code: ret.code,
|
|
176
|
-
map: bindingifySourcemap(map),
|
|
177
|
-
moduleType: ret.moduleType,
|
|
178
|
-
sideEffects: bindingifySideEffects(ret.moduleSideEffects),
|
|
179
|
-
};
|
|
180
|
-
},
|
|
181
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
182
|
-
filter: bindingifyLoadFilter(options.filter),
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
function preProcessSourceMap(ret, id) {
|
|
186
|
-
if (!ret.map) {
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
let map = typeof ret.map === 'object'
|
|
190
|
-
? ret.map
|
|
191
|
-
: JSON.parse(ret.map);
|
|
192
|
-
if (!isEmptySourcemapFiled(map.sources)) {
|
|
193
|
-
// normalize original sourcemap sources
|
|
194
|
-
// Port form https://github.com/rollup/rollup/blob/master/src/utils/collapseSourcemaps.ts#L180-L188.
|
|
195
|
-
const directory = path.dirname(id) || '.';
|
|
196
|
-
const sourceRoot = map.sourceRoot || '.';
|
|
197
|
-
map.sources = map.sources.map((source) => path.resolve(directory, sourceRoot, source));
|
|
198
|
-
}
|
|
199
|
-
return map;
|
|
200
|
-
}
|
|
201
|
-
export function bindingifyModuleParsed(args) {
|
|
202
|
-
const hook = args.plugin.moduleParsed;
|
|
203
|
-
if (!hook) {
|
|
204
|
-
return {};
|
|
205
|
-
}
|
|
206
|
-
const { handler, meta } = normalizeHook(hook);
|
|
207
|
-
return {
|
|
208
|
-
plugin: async (ctx, moduleInfo) => {
|
|
209
|
-
await handler.call(new PluginContext(ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), transformModuleInfo(moduleInfo, args.pluginContextData.getModuleOption(moduleInfo.id)));
|
|
210
|
-
},
|
|
211
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
212
|
-
};
|
|
213
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { StringFilter } from './hook-filter';
|
|
2
|
-
import type { HookFilterExtension } from '.';
|
|
3
|
-
import type { BindingGeneralHookFilter, BindingTransformHookFilter } from '../binding.d';
|
|
4
|
-
export declare function bindingifyStringFilter(matcher: StringFilter): BindingGeneralHookFilter;
|
|
5
|
-
export declare function bindingifyResolveIdFilter(filterOption?: HookFilterExtension<'resolveId'>['filter']): BindingGeneralHookFilter | undefined;
|
|
6
|
-
export declare function bindingifyLoadFilter(filterOption?: HookFilterExtension<'load'>['filter']): BindingGeneralHookFilter | undefined;
|
|
7
|
-
export declare function bindingifyTransformFilter(filterOption?: HookFilterExtension<'transform'>['filter']): BindingTransformHookFilter | undefined;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { arraify } from '../utils/misc';
|
|
2
|
-
export function bindingifyStringFilter(matcher) {
|
|
3
|
-
if (typeof matcher === 'string' || matcher instanceof RegExp) {
|
|
4
|
-
return { include: [matcher] };
|
|
5
|
-
}
|
|
6
|
-
if (Array.isArray(matcher)) {
|
|
7
|
-
return { include: matcher };
|
|
8
|
-
}
|
|
9
|
-
return {
|
|
10
|
-
include: matcher.include ? arraify(matcher.include) : undefined,
|
|
11
|
-
exclude: matcher.exclude ? arraify(matcher.exclude) : undefined,
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
export function bindingifyResolveIdFilter(filterOption) {
|
|
15
|
-
return filterOption?.id ? bindingifyStringFilter(filterOption.id) : undefined;
|
|
16
|
-
}
|
|
17
|
-
export function bindingifyLoadFilter(filterOption) {
|
|
18
|
-
return filterOption?.id ? bindingifyStringFilter(filterOption.id) : undefined;
|
|
19
|
-
}
|
|
20
|
-
export function bindingifyTransformFilter(filterOption) {
|
|
21
|
-
if (!filterOption) {
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
|
24
|
-
const { id, code, moduleType } = filterOption;
|
|
25
|
-
let moduleTypeRet;
|
|
26
|
-
if (moduleType) {
|
|
27
|
-
if (Array.isArray(moduleType)) {
|
|
28
|
-
moduleTypeRet = moduleType;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
moduleTypeRet = moduleType.include;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return {
|
|
35
|
-
id: id ? bindingifyStringFilter(id) : undefined,
|
|
36
|
-
code: code ? bindingifyStringFilter(code) : undefined,
|
|
37
|
-
moduleType: moduleTypeRet,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { PluginHookWithBindingExt } from './bindingify-plugin-hook-meta';
|
|
2
|
-
import type { BindingifyPluginArgs } from './bindingify-plugin';
|
|
3
|
-
import type { BindingPluginOptions } from '../binding';
|
|
4
|
-
export declare function bindingifyRenderStart(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['renderStart']>;
|
|
5
|
-
export declare function bindingifyRenderChunk(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['renderChunk']>;
|
|
6
|
-
export declare function bindingifyAugmentChunkHash(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['augmentChunkHash']>;
|
|
7
|
-
export declare function bindingifyRenderError(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['renderError']>;
|
|
8
|
-
export declare function bindingifyGenerateBundle(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['generateBundle']>;
|
|
9
|
-
export declare function bindingifyWriteBundle(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['writeBundle']>;
|
|
10
|
-
export declare function bindingifyCloseBundle(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['closeBundle']>;
|
|
11
|
-
export declare function bindingifyBanner(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['banner']>;
|
|
12
|
-
export declare function bindingifyFooter(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['footer']>;
|
|
13
|
-
export declare function bindingifyIntro(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['intro']>;
|
|
14
|
-
export declare function bindingifyOutro(args: BindingifyPluginArgs): PluginHookWithBindingExt<BindingPluginOptions['outro']>;
|