rolldown 1.0.0-beta.3-commit.306867e → 1.0.0-beta.3-commit.f65bde3
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/cjs/cli.cjs +2 -2
- package/dist/cjs/experimental-index.cjs +2 -2
- package/dist/cjs/index.cjs +2 -2
- package/dist/cjs/parallel-plugin-worker.cjs +2 -2
- package/dist/cjs/parse-ast-index.cjs +1 -1
- package/dist/esm/cli.mjs +2 -2
- package/dist/esm/experimental-index.mjs +2 -2
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/parallel-plugin-worker.mjs +2 -2
- package/dist/esm/parse-ast-index.mjs +1 -1
- package/dist/shared/{binding-_xN4hdfO.mjs → binding-CFTx0Fs7.mjs} +3 -3
- package/dist/shared/{binding-B9_Bsc0_.cjs → binding-DTKqYZn-.cjs} +3 -3
- package/dist/shared/{src-BGJCTYiA.mjs → src-46qAwcxx.mjs} +54 -17
- package/dist/shared/{src-BL6ftzBh.cjs → src-CoQJ2u3O.cjs} +54 -17
- package/dist/types/binding.d.ts +7 -0
- package/dist/types/index.d.ts +4 -3
- package/dist/types/log/logging.d.ts +1 -0
- package/dist/types/options/input-options.d.ts +2 -2
- package/dist/types/plugin/index.d.ts +1 -0
- package/dist/types/plugin/plugin-context-data.d.ts +2 -1
- package/package.json +19 -19
- package/dist/types/api/build.js +0 -22
- package/dist/types/api/experimental.js +0 -13
- package/dist/types/api/rolldown/index.js +0 -7
- package/dist/types/api/rolldown/rolldown-build.js +0 -43
- package/dist/types/api/watch/index.js +0 -8
- package/dist/types/api/watch/watch-emitter.js +0 -69
- package/dist/types/api/watch/watcher.js +0 -66
- package/dist/types/builtin-plugin/alias-plugin.js +0 -4
- package/dist/types/builtin-plugin/constructors.js +0 -68
- package/dist/types/builtin-plugin/replace-plugin.js +0 -29
- package/dist/types/builtin-plugin/transform-plugin.js +0 -16
- package/dist/types/builtin-plugin/utils.js +0 -19
- package/dist/types/cli/arguments/alias.js +0 -63
- package/dist/types/cli/arguments/index.js +0 -127
- package/dist/types/cli/arguments/normalize.js +0 -48
- package/dist/types/cli/arguments/utils.js +0 -67
- package/dist/types/cli/colors.js +0 -17
- package/dist/types/cli/commands/bundle.js +0 -203
- package/dist/types/cli/commands/help.js +0 -88
- package/dist/types/cli/index.js +0 -27
- package/dist/types/cli/load-config.js +0 -95
- package/dist/types/cli/logger.js +0 -35
- package/dist/types/constants/plugin-context.js +0 -7
- package/dist/types/constants/plugin.js +0 -69
- package/dist/types/experimental-index.js +0 -9
- package/dist/types/index.js +0 -7
- package/dist/types/log/logHandler.js +0 -25
- package/dist/types/log/logger.js +0 -107
- package/dist/types/log/logging.js +0 -11
- package/dist/types/log/logs.js +0 -86
- package/dist/types/options/input-options.js +0 -1
- package/dist/types/options/normalized-input-options.js +0 -21
- package/dist/types/options/normalized-output-options.js +0 -99
- package/dist/types/options/output-options.js +0 -1
- package/dist/types/options/watch-options.js +0 -1
- package/dist/types/parallel-plugin-worker.js +0 -31
- package/dist/types/parallel-plugin.js +0 -1
- package/dist/types/parse-ast-index.js +0 -73
- package/dist/types/plugin/bindingify-build-hooks.js +0 -213
- package/dist/types/plugin/bindingify-hook-filter.js +0 -39
- package/dist/types/plugin/bindingify-output-hooks.js +0 -189
- package/dist/types/plugin/bindingify-plugin-hook-meta.js +0 -19
- package/dist/types/plugin/bindingify-plugin.js +0 -124
- package/dist/types/plugin/bindingify-watch-hooks.js +0 -29
- package/dist/types/plugin/hook-filter.js +0 -1
- package/dist/types/plugin/index.js +0 -1
- package/dist/types/plugin/minimal-plugin-context.js +0 -25
- package/dist/types/plugin/parallel-plugin-implementation.js +0 -3
- package/dist/types/plugin/parallel-plugin.js +0 -6
- package/dist/types/plugin/plugin-context-data.js +0 -55
- package/dist/types/plugin/plugin-context.js +0 -124
- package/dist/types/plugin/plugin-driver.js +0 -88
- package/dist/types/plugin/transform-plugin-context.js +0 -37
- package/dist/types/types/assert.js +0 -1
- package/dist/types/types/config-export.js +0 -1
- package/dist/types/types/misc.js +0 -1
- package/dist/types/types/module-info.js +0 -1
- package/dist/types/types/module-side-effects.js +0 -1
- package/dist/types/types/output-bundle.js +0 -1
- package/dist/types/types/rolldown-options.js +0 -1
- package/dist/types/types/rolldown-output.js +0 -1
- package/dist/types/types/schema.js +0 -1
- package/dist/types/types/sourcemap.js +0 -16
- package/dist/types/types/utils.js +0 -1
- package/dist/types/utils/asset-source.js +0 -8
- package/dist/types/utils/async-flatten.js +0 -7
- package/dist/types/utils/bindingify-input-options.js +0 -226
- package/dist/types/utils/bindingify-output-options.js +0 -107
- package/dist/types/utils/code-frame.js +0 -46
- package/dist/types/utils/compose-js-plugins.js +0 -400
- package/dist/types/utils/create-bundler-option.js +0 -53
- package/dist/types/utils/create-bundler.js +0 -15
- package/dist/types/utils/define-config.js +0 -3
- package/dist/types/utils/error.js +0 -65
- package/dist/types/utils/initialize-parallel-plugins.js +0 -54
- package/dist/types/utils/misc.js +0 -22
- package/dist/types/utils/normalize-hook.js +0 -21
- package/dist/types/utils/normalize-plugin-option.js +0 -35
- package/dist/types/utils/normalize-string-or-regex.js +0 -14
- package/dist/types/utils/plugin/index.js +0 -7
- package/dist/types/utils/transform-module-info.js +0 -19
- package/dist/types/utils/transform-rendered-chunk.js +0 -43
- package/dist/types/utils/transform-rendered-module.js +0 -10
- package/dist/types/utils/transform-side-effects.js +0 -16
- package/dist/types/utils/transform-sourcemap.js +0 -29
- package/dist/types/utils/transform-to-rollup-output.js +0 -165
- package/dist/types/utils/validator.js +0 -276
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Normalize single or multiple string or regex patterns to an array of BindingStringOrRegex
|
|
3
|
-
* convert a type that is dx friendly to a type that is friendly for binding usage
|
|
4
|
-
*
|
|
5
|
-
* */
|
|
6
|
-
export function normalizedStringOrRegex(pattern) {
|
|
7
|
-
if (!pattern) {
|
|
8
|
-
return undefined;
|
|
9
|
-
}
|
|
10
|
-
if (!Array.isArray(pattern)) {
|
|
11
|
-
pattern = [pattern];
|
|
12
|
-
}
|
|
13
|
-
return pattern;
|
|
14
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { ENUMERATED_PLUGIN_HOOK_NAMES, } from '../../constants/plugin';
|
|
2
|
-
export const isPluginHookName = (function () {
|
|
3
|
-
const PLUGIN_HOOK_NAMES_SET = new Set(ENUMERATED_PLUGIN_HOOK_NAMES);
|
|
4
|
-
return function isPluginHookName(hookName) {
|
|
5
|
-
return PLUGIN_HOOK_NAMES_SET.has(hookName);
|
|
6
|
-
};
|
|
7
|
-
})();
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { unsupported } from './misc';
|
|
2
|
-
export function transformModuleInfo(info, option) {
|
|
3
|
-
return {
|
|
4
|
-
get ast() {
|
|
5
|
-
return unsupported('ModuleInfo#ast');
|
|
6
|
-
},
|
|
7
|
-
get code() {
|
|
8
|
-
return info.code;
|
|
9
|
-
},
|
|
10
|
-
id: info.id,
|
|
11
|
-
importers: info.importers,
|
|
12
|
-
dynamicImporters: info.dynamicImporters,
|
|
13
|
-
importedIds: info.importedIds,
|
|
14
|
-
dynamicallyImportedIds: info.dynamicallyImportedIds,
|
|
15
|
-
exports: info.exports,
|
|
16
|
-
isEntry: info.isEntry,
|
|
17
|
-
...option,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { transformToRenderedModule } from './transform-rendered-module';
|
|
2
|
-
export function transformRenderedChunk(chunk) {
|
|
3
|
-
return {
|
|
4
|
-
get name() {
|
|
5
|
-
return chunk.name;
|
|
6
|
-
},
|
|
7
|
-
get isEntry() {
|
|
8
|
-
return chunk.isEntry;
|
|
9
|
-
},
|
|
10
|
-
get isDynamicEntry() {
|
|
11
|
-
return chunk.isDynamicEntry;
|
|
12
|
-
},
|
|
13
|
-
get facadeModuleId() {
|
|
14
|
-
return chunk.facadeModuleId;
|
|
15
|
-
},
|
|
16
|
-
get moduleIds() {
|
|
17
|
-
return chunk.moduleIds;
|
|
18
|
-
},
|
|
19
|
-
get exports() {
|
|
20
|
-
return chunk.exports;
|
|
21
|
-
},
|
|
22
|
-
get fileName() {
|
|
23
|
-
return chunk.fileName;
|
|
24
|
-
},
|
|
25
|
-
get imports() {
|
|
26
|
-
return chunk.imports;
|
|
27
|
-
},
|
|
28
|
-
get dynamicImports() {
|
|
29
|
-
return chunk.dynamicImports;
|
|
30
|
-
},
|
|
31
|
-
get modules() {
|
|
32
|
-
return transformChunkModules(chunk.modules);
|
|
33
|
-
},
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export function transformChunkModules(modules) {
|
|
37
|
-
const result = {};
|
|
38
|
-
for (const [id, index] of Object.entries(modules.idToIndex)) {
|
|
39
|
-
let mod = modules.value[index];
|
|
40
|
-
result[id] = transformToRenderedModule(mod);
|
|
41
|
-
}
|
|
42
|
-
return result;
|
|
43
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { BindingHookSideEffects } from '../binding';
|
|
2
|
-
export function bindingifySideEffects(sideEffects) {
|
|
3
|
-
switch (sideEffects) {
|
|
4
|
-
case true:
|
|
5
|
-
return BindingHookSideEffects.True;
|
|
6
|
-
case false:
|
|
7
|
-
return BindingHookSideEffects.False;
|
|
8
|
-
case 'no-treeshake':
|
|
9
|
-
return BindingHookSideEffects.NoTreeshake;
|
|
10
|
-
case null:
|
|
11
|
-
case undefined:
|
|
12
|
-
return undefined;
|
|
13
|
-
default:
|
|
14
|
-
throw new Error(`Unexpected side effects: ${sideEffects}`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export function isEmptySourcemapFiled(array) {
|
|
2
|
-
if (!array) {
|
|
3
|
-
return true;
|
|
4
|
-
}
|
|
5
|
-
if (array.length === 0 || !array[0] /* null or '' */) {
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
return false;
|
|
9
|
-
}
|
|
10
|
-
export function normalizeTransformHookSourcemap(id, originalCode, rawMap) {
|
|
11
|
-
if (!rawMap) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
// If sourcemap hasn't `sourcesContent` and `sources`, using original code to fill it.
|
|
15
|
-
// The rust side already has the feature at `crates/rolldown_plugin/src/plugin_driver/build_hooks.rs#transform`.
|
|
16
|
-
// but it could be failed at `rolldown_sourcemap::SourceMap::from_json`, because the map is invalid.
|
|
17
|
-
let map = typeof rawMap === 'object'
|
|
18
|
-
? rawMap
|
|
19
|
-
: JSON.parse(rawMap);
|
|
20
|
-
if (isEmptySourcemapFiled(map.sourcesContent)) {
|
|
21
|
-
map.sourcesContent = [originalCode];
|
|
22
|
-
}
|
|
23
|
-
if (isEmptySourcemapFiled(map.sources) ||
|
|
24
|
-
(map.sources && map.sources.length === 1 && map.sources[0] !== id) // the transform sourcemaps maybe contain multiple sources
|
|
25
|
-
) {
|
|
26
|
-
map.sources = [id];
|
|
27
|
-
}
|
|
28
|
-
return map;
|
|
29
|
-
}
|
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import { bindingAssetSource, transformAssetSource, } from './asset-source';
|
|
2
|
-
import { bindingifySourcemap } from '../types/sourcemap';
|
|
3
|
-
import { normalizeErrors } from './error';
|
|
4
|
-
import { transformChunkModules } from './transform-rendered-chunk';
|
|
5
|
-
import { Buffer } from 'node:buffer';
|
|
6
|
-
function transformToRollupSourceMap(map) {
|
|
7
|
-
const parsed = JSON.parse(map);
|
|
8
|
-
const obj = {
|
|
9
|
-
...parsed,
|
|
10
|
-
toString() {
|
|
11
|
-
return JSON.stringify(obj);
|
|
12
|
-
},
|
|
13
|
-
toUrl() {
|
|
14
|
-
return `data:application/json;charset=utf-8;base64,${Buffer.from(obj.toString(), 'utf-8').toString('base64')}`;
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
return obj;
|
|
18
|
-
}
|
|
19
|
-
function transformToRollupOutputChunk(bindingChunk, changed) {
|
|
20
|
-
const chunk = {
|
|
21
|
-
type: 'chunk',
|
|
22
|
-
get code() {
|
|
23
|
-
return bindingChunk.code;
|
|
24
|
-
},
|
|
25
|
-
fileName: bindingChunk.fileName,
|
|
26
|
-
name: bindingChunk.name,
|
|
27
|
-
get modules() {
|
|
28
|
-
return transformChunkModules(bindingChunk.modules);
|
|
29
|
-
},
|
|
30
|
-
get imports() {
|
|
31
|
-
return bindingChunk.imports;
|
|
32
|
-
},
|
|
33
|
-
get dynamicImports() {
|
|
34
|
-
return bindingChunk.dynamicImports;
|
|
35
|
-
},
|
|
36
|
-
exports: bindingChunk.exports,
|
|
37
|
-
isEntry: bindingChunk.isEntry,
|
|
38
|
-
facadeModuleId: bindingChunk.facadeModuleId || null,
|
|
39
|
-
isDynamicEntry: bindingChunk.isDynamicEntry,
|
|
40
|
-
get moduleIds() {
|
|
41
|
-
return bindingChunk.moduleIds;
|
|
42
|
-
},
|
|
43
|
-
get map() {
|
|
44
|
-
return bindingChunk.map
|
|
45
|
-
? transformToRollupSourceMap(bindingChunk.map)
|
|
46
|
-
: null;
|
|
47
|
-
},
|
|
48
|
-
sourcemapFileName: bindingChunk.sourcemapFileName || null,
|
|
49
|
-
preliminaryFileName: bindingChunk.preliminaryFileName,
|
|
50
|
-
};
|
|
51
|
-
const cache = {};
|
|
52
|
-
return new Proxy(chunk, {
|
|
53
|
-
get(target, p) {
|
|
54
|
-
if (p in cache) {
|
|
55
|
-
return cache[p];
|
|
56
|
-
}
|
|
57
|
-
return target[p];
|
|
58
|
-
},
|
|
59
|
-
set(target, p, newValue) {
|
|
60
|
-
cache[p] = newValue;
|
|
61
|
-
changed?.updated.add(bindingChunk.fileName);
|
|
62
|
-
return true;
|
|
63
|
-
},
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
function transformToRollupOutputAsset(bindingAsset, changed) {
|
|
67
|
-
const asset = {
|
|
68
|
-
type: 'asset',
|
|
69
|
-
fileName: bindingAsset.fileName,
|
|
70
|
-
originalFileName: bindingAsset.originalFileName || null,
|
|
71
|
-
originalFileNames: bindingAsset.originalFileNames,
|
|
72
|
-
get source() {
|
|
73
|
-
return transformAssetSource(bindingAsset.source);
|
|
74
|
-
},
|
|
75
|
-
name: bindingAsset.name ?? undefined,
|
|
76
|
-
names: bindingAsset.names,
|
|
77
|
-
};
|
|
78
|
-
const cache = {};
|
|
79
|
-
return new Proxy(asset, {
|
|
80
|
-
get(target, p) {
|
|
81
|
-
if (p in cache) {
|
|
82
|
-
return cache[p];
|
|
83
|
-
}
|
|
84
|
-
return target[p];
|
|
85
|
-
},
|
|
86
|
-
set(target, p, newValue) {
|
|
87
|
-
cache[p] = newValue;
|
|
88
|
-
changed?.updated.add(bindingAsset.fileName);
|
|
89
|
-
return true;
|
|
90
|
-
},
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
export function transformToRollupOutput(output, changed) {
|
|
94
|
-
handleOutputErrors(output);
|
|
95
|
-
const { chunks, assets } = output;
|
|
96
|
-
return {
|
|
97
|
-
output: [
|
|
98
|
-
...chunks.map((chunk) => transformToRollupOutputChunk(chunk, changed)),
|
|
99
|
-
...assets.map((asset) => transformToRollupOutputAsset(asset, changed)),
|
|
100
|
-
],
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
export function handleOutputErrors(output) {
|
|
104
|
-
const rawErrors = output.errors;
|
|
105
|
-
if (rawErrors.length > 0) {
|
|
106
|
-
throw normalizeErrors(rawErrors);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
export function transformToOutputBundle(output, changed) {
|
|
110
|
-
const bundle = Object.fromEntries(transformToRollupOutput(output, changed).output.map((item) => [
|
|
111
|
-
item.fileName,
|
|
112
|
-
item,
|
|
113
|
-
]));
|
|
114
|
-
return new Proxy(bundle, {
|
|
115
|
-
deleteProperty(target, property) {
|
|
116
|
-
if (typeof property === 'string') {
|
|
117
|
-
changed.deleted.add(property);
|
|
118
|
-
}
|
|
119
|
-
return true;
|
|
120
|
-
},
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
// TODO find a way only transfer the changed part to rust side.
|
|
124
|
-
export function collectChangedBundle(changed, bundle) {
|
|
125
|
-
const assets = [];
|
|
126
|
-
const chunks = [];
|
|
127
|
-
for (const key in bundle) {
|
|
128
|
-
if (changed.deleted.has(key) || !changed.updated.has(key)) {
|
|
129
|
-
continue;
|
|
130
|
-
}
|
|
131
|
-
const item = bundle[key];
|
|
132
|
-
if (item.type === 'asset') {
|
|
133
|
-
assets.push({
|
|
134
|
-
filename: item.fileName,
|
|
135
|
-
originalFileNames: item.originalFileNames,
|
|
136
|
-
source: bindingAssetSource(item.source),
|
|
137
|
-
names: item.names,
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
else {
|
|
141
|
-
// not all properties modifications are reflected to rust side
|
|
142
|
-
chunks.push({
|
|
143
|
-
code: item.code,
|
|
144
|
-
filename: item.fileName,
|
|
145
|
-
name: item.name,
|
|
146
|
-
isEntry: item.isEntry,
|
|
147
|
-
exports: item.exports,
|
|
148
|
-
modules: {},
|
|
149
|
-
imports: item.imports,
|
|
150
|
-
dynamicImports: item.dynamicImports,
|
|
151
|
-
facadeModuleId: item.facadeModuleId || undefined,
|
|
152
|
-
isDynamicEntry: item.isDynamicEntry,
|
|
153
|
-
moduleIds: item.moduleIds,
|
|
154
|
-
map: bindingifySourcemap(item.map),
|
|
155
|
-
sourcemapFilename: item.sourcemapFileName || undefined,
|
|
156
|
-
preliminaryFilename: item.preliminaryFileName,
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
return {
|
|
161
|
-
assets,
|
|
162
|
-
chunks,
|
|
163
|
-
deleted: Array.from(changed.deleted),
|
|
164
|
-
};
|
|
165
|
-
}
|
|
@@ -1,276 +0,0 @@
|
|
|
1
|
-
import * as v from 'valibot';
|
|
2
|
-
import { colors } from '../cli/colors';
|
|
3
|
-
import { toJsonSchema } from '@valibot/to-json-schema';
|
|
4
|
-
const StringOrRegExpSchema = v.union([v.string(), v.instance(RegExp)]);
|
|
5
|
-
const LogLevelSchema = v.union([
|
|
6
|
-
v.literal('debug'),
|
|
7
|
-
v.literal('info'),
|
|
8
|
-
v.literal('warn'),
|
|
9
|
-
]);
|
|
10
|
-
const LogLevelOptionSchema = v.union([LogLevelSchema, v.literal('silent')]);
|
|
11
|
-
const LogLevelWithErrorSchema = v.union([LogLevelSchema, v.literal('error')]);
|
|
12
|
-
const RollupLogSchema = v.any();
|
|
13
|
-
const RollupLogWithStringSchema = v.union([RollupLogSchema, v.string()]);
|
|
14
|
-
/// --- InputSchema ---
|
|
15
|
-
const InputOptionSchema = v.union([
|
|
16
|
-
v.string(),
|
|
17
|
-
v.array(v.string()),
|
|
18
|
-
v.record(v.string(), v.string()),
|
|
19
|
-
]);
|
|
20
|
-
const ExternalSchema = v.union([
|
|
21
|
-
StringOrRegExpSchema,
|
|
22
|
-
v.array(StringOrRegExpSchema),
|
|
23
|
-
v.pipe(v.function(), v.args(v.tuple([v.string(), v.optional(v.string()), v.boolean()])), v.returns(v.nullish(v.boolean()))),
|
|
24
|
-
]);
|
|
25
|
-
const ModuleTypesSchema = v.record(v.string(), v.union([
|
|
26
|
-
v.literal('base64'),
|
|
27
|
-
v.literal('binary'),
|
|
28
|
-
v.literal('css'),
|
|
29
|
-
v.literal('dataurl'),
|
|
30
|
-
v.literal('empty'),
|
|
31
|
-
v.literal('js'),
|
|
32
|
-
v.literal('json'),
|
|
33
|
-
v.literal('jsx'),
|
|
34
|
-
v.literal('text'),
|
|
35
|
-
v.literal('ts'),
|
|
36
|
-
v.literal('tsx'),
|
|
37
|
-
]));
|
|
38
|
-
const JsxOptionsSchema = v.strictObject({
|
|
39
|
-
development: v.pipe(v.optional(v.boolean()), v.description('Development specific information')),
|
|
40
|
-
factory: v.pipe(v.optional(v.string()), v.description('Jsx element transformation')),
|
|
41
|
-
fragment: v.pipe(v.optional(v.string()), v.description('Jsx fragment transformation')),
|
|
42
|
-
importSource: v.pipe(v.optional(v.string()), v.description('Import the factory of element and fragment if mode is classic')),
|
|
43
|
-
jsxImportSource: v.pipe(v.optional(v.string()), v.description('Import the factory of element and fragment if mode is automatic')),
|
|
44
|
-
mode: v.pipe(v.optional(v.union([v.literal('classic'), v.literal('automatic')])), v.description('Jsx transformation mode')),
|
|
45
|
-
refresh: v.pipe(v.optional(v.boolean()), v.description('React refresh transformation')),
|
|
46
|
-
});
|
|
47
|
-
const WatchOptionsSchema = v.strictObject({
|
|
48
|
-
chokidar: v.optional(v.any()),
|
|
49
|
-
exclude: v.optional(v.union([StringOrRegExpSchema, v.array(StringOrRegExpSchema)])),
|
|
50
|
-
include: v.optional(v.union([StringOrRegExpSchema, v.array(StringOrRegExpSchema)])),
|
|
51
|
-
notify: v.pipe(v.optional(v.strictObject({
|
|
52
|
-
compareContents: v.optional(v.boolean()),
|
|
53
|
-
pollInterval: v.optional(v.number()),
|
|
54
|
-
})), v.description('Notify options')),
|
|
55
|
-
skipWrite: v.pipe(v.optional(v.boolean()), v.description('Skip the bundle.write() step')),
|
|
56
|
-
});
|
|
57
|
-
const ChecksOptionsSchema = v.strictObject({
|
|
58
|
-
circularDependency: v.pipe(v.optional(v.boolean()), v.description('Wether to emit warnings when detecting circular dependencies')),
|
|
59
|
-
});
|
|
60
|
-
const ResolveOptionsSchema = v.strictObject({
|
|
61
|
-
alias: v.optional(v.record(v.string(), v.union([v.string(), v.array(v.string())]))),
|
|
62
|
-
aliasFields: v.optional(v.array(v.array(v.string()))),
|
|
63
|
-
conditionNames: v.optional(v.array(v.string())),
|
|
64
|
-
extensionAlias: v.optional(v.record(v.string(), v.array(v.string()))),
|
|
65
|
-
exportsFields: v.optional(v.array(v.array(v.string()))),
|
|
66
|
-
extensions: v.optional(v.array(v.string())),
|
|
67
|
-
mainFields: v.optional(v.array(v.string())),
|
|
68
|
-
mainFiles: v.optional(v.array(v.string())),
|
|
69
|
-
modules: v.optional(v.array(v.string())),
|
|
70
|
-
symlinks: v.optional(v.boolean()),
|
|
71
|
-
tsconfigFilename: v.optional(v.string()),
|
|
72
|
-
});
|
|
73
|
-
const TreeshakingOptionsSchema = v.union([
|
|
74
|
-
v.boolean(),
|
|
75
|
-
v.looseObject({ annotations: v.optional(v.boolean()) }),
|
|
76
|
-
]);
|
|
77
|
-
const OnLogSchema = v.pipe(v.function(), v.args(v.tuple([
|
|
78
|
-
LogLevelSchema,
|
|
79
|
-
RollupLogSchema,
|
|
80
|
-
v.pipe(v.function(), v.args(v.tuple([LogLevelWithErrorSchema, RollupLogWithStringSchema]))),
|
|
81
|
-
])));
|
|
82
|
-
const OnwarnSchema = v.pipe(v.function(), v.args(v.tuple([
|
|
83
|
-
RollupLogSchema,
|
|
84
|
-
v.pipe(v.function(), v.args(v.tuple([
|
|
85
|
-
v.union([
|
|
86
|
-
RollupLogWithStringSchema,
|
|
87
|
-
v.pipe(v.function(), v.returns(RollupLogWithStringSchema)),
|
|
88
|
-
]),
|
|
89
|
-
]))),
|
|
90
|
-
])));
|
|
91
|
-
const InputOptionsSchema = v.strictObject({
|
|
92
|
-
input: v.optional(InputOptionSchema),
|
|
93
|
-
plugins: v.optional(v.custom(() => true)),
|
|
94
|
-
external: v.optional(ExternalSchema),
|
|
95
|
-
resolve: v.optional(ResolveOptionsSchema),
|
|
96
|
-
cwd: v.pipe(v.optional(v.string()), v.description('Current working directory')),
|
|
97
|
-
platform: v.pipe(v.optional(v.union([v.literal('browser'), v.literal('neutral'), v.literal('node')])), v.description(`Platform for which the code should be generated (node, ${colors.underline('browser')}, neutral)`)),
|
|
98
|
-
shimMissingExports: v.pipe(v.optional(v.boolean()), v.description('Create shim variables for missing exports')),
|
|
99
|
-
treeshake: v.optional(TreeshakingOptionsSchema),
|
|
100
|
-
logLevel: v.pipe(v.optional(LogLevelOptionSchema), v.description(`Log level (${colors.dim('silent')}, ${colors.underline(colors.gray('info'))}, debug, ${colors.yellow('warn')})`)),
|
|
101
|
-
onLog: v.optional(OnLogSchema),
|
|
102
|
-
onwarn: v.optional(OnwarnSchema),
|
|
103
|
-
moduleTypes: v.pipe(v.optional(ModuleTypesSchema), v.description('Module types for customized extensions')),
|
|
104
|
-
experimental: v.optional(v.strictObject({
|
|
105
|
-
disableLiveBindings: v.optional(v.boolean()),
|
|
106
|
-
enableComposingJsPlugins: v.optional(v.boolean()),
|
|
107
|
-
resolveNewUrlToAsset: v.optional(v.boolean()),
|
|
108
|
-
strictExecutionOrder: v.optional(v.boolean()),
|
|
109
|
-
hmr: v.optional(v.boolean()),
|
|
110
|
-
})),
|
|
111
|
-
define: v.pipe(v.optional(v.record(v.string(), v.string())), v.description('Define global variables')),
|
|
112
|
-
inject: v.optional(v.record(v.string(), v.union([v.string(), v.tuple([v.string(), v.string()])]))),
|
|
113
|
-
profilerNames: v.optional(v.boolean()),
|
|
114
|
-
jsx: v.optional(JsxOptionsSchema),
|
|
115
|
-
watch: v.optional(v.union([WatchOptionsSchema, v.literal(false)])),
|
|
116
|
-
dropLabels: v.pipe(v.optional(v.array(v.string())), v.description('Remove labeled statements with these label names')),
|
|
117
|
-
checks: v.optional(ChecksOptionsSchema),
|
|
118
|
-
});
|
|
119
|
-
const InputCliOverrideSchema = v.strictObject({
|
|
120
|
-
external: v.pipe(v.optional(v.array(v.string())), v.description('Comma-separated list of module ids to exclude from the bundle `<module-id>,...`')),
|
|
121
|
-
inject: v.pipe(v.optional(v.record(v.string(), v.string())), v.description('Inject import statements on demand')),
|
|
122
|
-
treeshake: v.pipe(v.optional(v.boolean()), v.description('enable treeshaking')),
|
|
123
|
-
});
|
|
124
|
-
const InputCliOptionsSchema = v.omit(v.strictObject({
|
|
125
|
-
...InputOptionsSchema.entries,
|
|
126
|
-
...InputCliOverrideSchema.entries,
|
|
127
|
-
}), [
|
|
128
|
-
'input',
|
|
129
|
-
'plugins',
|
|
130
|
-
'onwarn',
|
|
131
|
-
'onLog',
|
|
132
|
-
'resolve',
|
|
133
|
-
'experimental',
|
|
134
|
-
'profilerNames',
|
|
135
|
-
'watch',
|
|
136
|
-
]);
|
|
137
|
-
/// --- OutputSchema ---
|
|
138
|
-
var ESTarget;
|
|
139
|
-
(function (ESTarget) {
|
|
140
|
-
ESTarget["ES6"] = "es6";
|
|
141
|
-
ESTarget["ES2015"] = "es2015";
|
|
142
|
-
ESTarget["ES2016"] = "es2016";
|
|
143
|
-
ESTarget["ES2017"] = "es2017";
|
|
144
|
-
ESTarget["ES2018"] = "es2018";
|
|
145
|
-
ESTarget["ES2019"] = "es2019";
|
|
146
|
-
ESTarget["ES2020"] = "es2020";
|
|
147
|
-
ESTarget["ES2021"] = "es2021";
|
|
148
|
-
ESTarget["ES2022"] = "es2022";
|
|
149
|
-
ESTarget["ES2023"] = "es2023";
|
|
150
|
-
ESTarget["ES2024"] = "es2024";
|
|
151
|
-
ESTarget["ESNext"] = "esnext";
|
|
152
|
-
})(ESTarget || (ESTarget = {}));
|
|
153
|
-
const ModuleFormatSchema = v.union([
|
|
154
|
-
v.literal('es'),
|
|
155
|
-
v.literal('cjs'),
|
|
156
|
-
v.literal('esm'),
|
|
157
|
-
v.literal('module'),
|
|
158
|
-
v.literal('commonjs'),
|
|
159
|
-
v.literal('iife'),
|
|
160
|
-
v.literal('umd'),
|
|
161
|
-
]);
|
|
162
|
-
const AddonFunctionSchema = v.pipe(v.function(), v.args(v.tuple([v.custom(() => true)])), v.returnsAsync(v.unionAsync([
|
|
163
|
-
v.string(),
|
|
164
|
-
v.pipeAsync(v.promise(), v.awaitAsync(), v.string()),
|
|
165
|
-
])));
|
|
166
|
-
const ChunkFileNamesSchema = v.union([
|
|
167
|
-
v.string(),
|
|
168
|
-
v.pipe(v.function(), v.args(v.tuple([v.custom(() => true)])), v.returns(v.string())),
|
|
169
|
-
]);
|
|
170
|
-
const GlobalsFunctionSchema = v.pipe(v.function(), v.args(v.tuple([v.string()])), v.returns(v.string()));
|
|
171
|
-
const AdvancedChunksSchema = v.strictObject({
|
|
172
|
-
minSize: v.optional(v.number()),
|
|
173
|
-
maxSize: v.optional(v.number()),
|
|
174
|
-
minModuleSize: v.optional(v.number()),
|
|
175
|
-
maxModuleSize: v.optional(v.number()),
|
|
176
|
-
minShareCount: v.optional(v.number()),
|
|
177
|
-
groups: v.optional(v.array(v.strictObject({
|
|
178
|
-
name: v.string(),
|
|
179
|
-
test: v.optional(v.union([v.string(), v.instance(RegExp)])),
|
|
180
|
-
priority: v.optional(v.number()),
|
|
181
|
-
minSize: v.optional(v.number()),
|
|
182
|
-
minShareCount: v.optional(v.number()),
|
|
183
|
-
maxSize: v.optional(v.number()),
|
|
184
|
-
minModuleSize: v.optional(v.number()),
|
|
185
|
-
maxModuleSize: v.optional(v.number()),
|
|
186
|
-
}))),
|
|
187
|
-
});
|
|
188
|
-
const OutputOptionsSchema = v.strictObject({
|
|
189
|
-
dir: v.pipe(v.optional(v.string()), v.description('Output directory, defaults to `dist` if `file` is not set')),
|
|
190
|
-
file: v.pipe(v.optional(v.string()), v.description('Single output file')),
|
|
191
|
-
exports: v.pipe(v.optional(v.union([
|
|
192
|
-
v.literal('auto'),
|
|
193
|
-
v.literal('named'),
|
|
194
|
-
v.literal('default'),
|
|
195
|
-
v.literal('none'),
|
|
196
|
-
])), v.description(`Specify a export mode (${colors.underline('auto')}, named, default, none)`)),
|
|
197
|
-
hashCharacters: v.pipe(v.optional(v.union([v.literal('base64'), v.literal('base36'), v.literal('hex')])), v.description('Use the specified character set for file hashes')),
|
|
198
|
-
format: v.pipe(v.optional(ModuleFormatSchema), v.description(`Output format of the generated bundle (supports ${colors.underline('esm')}, cjs, and iife)`)),
|
|
199
|
-
sourcemap: v.pipe(v.optional(v.union([v.boolean(), v.literal('inline'), v.literal('hidden')])), v.description(`Generate sourcemap (\`-s inline\` for inline, or ${colors.bold('pass the `-s` on the last argument if you want to generate `.map` file')})`)),
|
|
200
|
-
sourcemapIgnoreList: v.optional(v.union([v.boolean(), v.custom(() => true)])),
|
|
201
|
-
sourcemapPathTransform: v.optional(v.custom(() => true)),
|
|
202
|
-
banner: v.optional(v.union([v.string(), AddonFunctionSchema])),
|
|
203
|
-
footer: v.optional(v.union([v.string(), AddonFunctionSchema])),
|
|
204
|
-
intro: v.optional(v.union([v.string(), AddonFunctionSchema])),
|
|
205
|
-
outro: v.optional(v.union([v.string(), AddonFunctionSchema])),
|
|
206
|
-
extend: v.pipe(v.optional(v.boolean()), v.description('Extend global variable defined by name in IIFE / UMD formats')),
|
|
207
|
-
esModule: v.optional(v.union([v.boolean(), v.literal('if-default-prop')])),
|
|
208
|
-
assetFileNames: v.pipe(v.optional(v.string()), v.description('Name pattern for asset files')),
|
|
209
|
-
entryFileNames: v.optional(ChunkFileNamesSchema),
|
|
210
|
-
chunkFileNames: v.optional(ChunkFileNamesSchema),
|
|
211
|
-
cssEntryFileNames: v.optional(ChunkFileNamesSchema),
|
|
212
|
-
cssChunkFileNames: v.optional(ChunkFileNamesSchema),
|
|
213
|
-
minify: v.pipe(v.optional(v.boolean()), v.description('Minify the bundled file')),
|
|
214
|
-
name: v.pipe(v.optional(v.string()), v.description('Name for UMD / IIFE format outputs')),
|
|
215
|
-
globals: v.pipe(v.optional(v.union([v.record(v.string(), v.string()), GlobalsFunctionSchema])), v.description('Global variable of UMD / IIFE dependencies (syntax: `key=value`)')),
|
|
216
|
-
externalLiveBindings: v.pipe(v.optional(v.boolean(), true), v.description('external live bindings')),
|
|
217
|
-
inlineDynamicImports: v.pipe(v.optional(v.boolean(), false), v.description('Inline dynamic imports')),
|
|
218
|
-
advancedChunks: v.optional(AdvancedChunksSchema),
|
|
219
|
-
comments: v.pipe(v.optional(v.union([v.literal('none'), v.literal('preserve-legal')])), v.description('Control comments in the output')),
|
|
220
|
-
target: v.pipe(v.optional(v.enum(ESTarget)), v.description('The JavaScript target environment')),
|
|
221
|
-
});
|
|
222
|
-
const getAddonDescription = (placement, wrapper) => {
|
|
223
|
-
return `Code to insert the ${colors.bold(placement)} of the bundled file (${colors.bold(wrapper)} the wrapper function)`;
|
|
224
|
-
};
|
|
225
|
-
const OutputCliOverrideSchema = v.strictObject({
|
|
226
|
-
// Reject all functions in CLI
|
|
227
|
-
entryFileNames: v.pipe(v.optional(v.string()), v.description('Name pattern for emitted entry chunks')),
|
|
228
|
-
chunkFileNames: v.pipe(v.optional(v.string()), v.description('Name pattern for emitted secondary chunks')),
|
|
229
|
-
cssEntryFileNames: v.pipe(v.optional(v.string()), v.description('Name pattern for emitted css entry chunks')),
|
|
230
|
-
cssChunkFileNames: v.pipe(v.optional(v.string()), v.description('Name pattern for emitted css secondary chunks')),
|
|
231
|
-
banner: v.pipe(v.optional(v.string()), v.description(getAddonDescription('top', 'outside'))),
|
|
232
|
-
footer: v.pipe(v.optional(v.string()), v.description(getAddonDescription('bottom', 'outside'))),
|
|
233
|
-
intro: v.pipe(v.optional(v.string()), v.description(getAddonDescription('top', 'inside'))),
|
|
234
|
-
outro: v.pipe(v.optional(v.string()), v.description(getAddonDescription('bottom', 'inside'))),
|
|
235
|
-
// It is hard to handle the union type in json schema, so use this first.
|
|
236
|
-
esModule: v.pipe(v.optional(v.boolean()), v.description('Always generate `__esModule` marks in non-ESM formats, defaults to `if-default-prop` (use `--no-esModule` to always disable)')),
|
|
237
|
-
globals: v.pipe(v.optional(v.record(v.string(), v.string())), v.description('Global variable of UMD / IIFE dependencies (syntax: `key=value`)')),
|
|
238
|
-
advancedChunks: v.pipe(v.optional(v.strictObject({
|
|
239
|
-
minSize: v.pipe(v.optional(v.number()), v.description('Minimum size of the chunk')),
|
|
240
|
-
minShareCount: v.pipe(v.optional(v.number()), v.description('Minimum share count of the chunk')),
|
|
241
|
-
})), v.description('Global variable of UMD / IIFE dependencies (syntax: `key=value`)')),
|
|
242
|
-
});
|
|
243
|
-
const OutputCliOptionsSchema = v.omit(v.strictObject({
|
|
244
|
-
...OutputOptionsSchema.entries,
|
|
245
|
-
...OutputCliOverrideSchema.entries,
|
|
246
|
-
}), ['sourcemapIgnoreList', 'sourcemapPathTransform']);
|
|
247
|
-
/// --- CliSchema ---
|
|
248
|
-
const CliOptionsSchema = v.strictObject({
|
|
249
|
-
config: v.pipe(v.optional(v.union([v.string(), v.boolean()])), v.description('Path to the config file (default: `rolldown.config.js`)')),
|
|
250
|
-
help: v.pipe(v.optional(v.boolean()), v.description('Show help')),
|
|
251
|
-
version: v.pipe(v.optional(v.boolean()), v.description('Show version number')),
|
|
252
|
-
watch: v.pipe(v.optional(v.boolean()), v.description('Watch files in bundle and rebuild on changes')),
|
|
253
|
-
...InputCliOptionsSchema.entries,
|
|
254
|
-
...OutputCliOptionsSchema.entries,
|
|
255
|
-
});
|
|
256
|
-
export function validateTreeShakingOptions(options) {
|
|
257
|
-
v.parse(TreeshakingOptionsSchema, options);
|
|
258
|
-
}
|
|
259
|
-
export function validateCliOptions(options) {
|
|
260
|
-
let parsed = v.safeParse(CliOptionsSchema, options);
|
|
261
|
-
return [
|
|
262
|
-
parsed.output,
|
|
263
|
-
parsed.issues
|
|
264
|
-
?.map((issue) => issue.path?.join(', '))
|
|
265
|
-
.filter((v) => v !== undefined),
|
|
266
|
-
];
|
|
267
|
-
}
|
|
268
|
-
export function getInputCliKeys() {
|
|
269
|
-
return v.keyof(InputCliOptionsSchema).options;
|
|
270
|
-
}
|
|
271
|
-
export function getOutputCliKeys() {
|
|
272
|
-
return v.keyof(OutputCliOptionsSchema).options;
|
|
273
|
-
}
|
|
274
|
-
export function getJsonSchema() {
|
|
275
|
-
return toJsonSchema(CliOptionsSchema);
|
|
276
|
-
}
|