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,37 +0,0 @@
|
|
|
1
|
-
import { normalizeLog } from '../log/logHandler';
|
|
2
|
-
import { PluginContext } from './plugin-context';
|
|
3
|
-
import { augmentCodeLocation, error, logPluginError } from '../log/logs';
|
|
4
|
-
export class TransformPluginContext extends PluginContext {
|
|
5
|
-
inner;
|
|
6
|
-
moduleId;
|
|
7
|
-
moduleSource;
|
|
8
|
-
constructor(outputOptions, context, plugin, data, inner, moduleId, moduleSource, onLog, LogLevelOption) {
|
|
9
|
-
super(outputOptions, context, plugin, data, onLog, LogLevelOption, moduleId);
|
|
10
|
-
this.inner = inner;
|
|
11
|
-
this.moduleId = moduleId;
|
|
12
|
-
this.moduleSource = moduleSource;
|
|
13
|
-
const getLogHandler = (handler) => (log, pos) => {
|
|
14
|
-
log = normalizeLog(log);
|
|
15
|
-
if (pos)
|
|
16
|
-
augmentCodeLocation(log, pos, moduleSource, moduleId);
|
|
17
|
-
log.id = moduleId;
|
|
18
|
-
log.hook = 'transform';
|
|
19
|
-
handler(log);
|
|
20
|
-
};
|
|
21
|
-
this.debug = getLogHandler(this.debug);
|
|
22
|
-
this.warn = getLogHandler(this.warn);
|
|
23
|
-
this.info = getLogHandler(this.info);
|
|
24
|
-
}
|
|
25
|
-
error(e, pos) {
|
|
26
|
-
if (typeof e === 'string')
|
|
27
|
-
e = { message: e };
|
|
28
|
-
if (pos)
|
|
29
|
-
augmentCodeLocation(e, pos, this.moduleSource, this.moduleId);
|
|
30
|
-
e.id = this.moduleId;
|
|
31
|
-
e.hook = 'transform';
|
|
32
|
-
return error(logPluginError(normalizeLog(e), this.pluginName));
|
|
33
|
-
}
|
|
34
|
-
getCombinedSourcemap() {
|
|
35
|
-
return JSON.parse(this.inner.getCombinedSourcemap());
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/types/types/misc.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export function bindingifySourcemap(map) {
|
|
2
|
-
if (map == null)
|
|
3
|
-
return;
|
|
4
|
-
return {
|
|
5
|
-
inner: typeof map === 'string'
|
|
6
|
-
? map
|
|
7
|
-
: {
|
|
8
|
-
file: map.file ?? undefined,
|
|
9
|
-
mappings: map.mappings,
|
|
10
|
-
sourceRoot: map.sourceRoot,
|
|
11
|
-
sources: map.sources?.map((s) => s ?? undefined),
|
|
12
|
-
sourcesContent: map.sourcesContent?.map((s) => s ?? undefined),
|
|
13
|
-
names: map.names,
|
|
14
|
-
},
|
|
15
|
-
};
|
|
16
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// Copied from https://github.com/rollup/rollup/blob/3b560f7c889a63968dabc9b6970aabf52a77d3fd/src/utils/asyncFlatten.ts
|
|
2
|
-
export async function asyncFlatten(array) {
|
|
3
|
-
do {
|
|
4
|
-
array = (await Promise.all(array)).flat(Infinity);
|
|
5
|
-
} while (array.some((v) => v?.then));
|
|
6
|
-
return array;
|
|
7
|
-
}
|
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import { BindingLogLevel } from '../binding';
|
|
2
|
-
import { bindingifyPlugin } from '../plugin/bindingify-plugin';
|
|
3
|
-
import { PluginContextData } from '../plugin/plugin-context-data';
|
|
4
|
-
import { bindingifyBuiltInPlugin } from '../builtin-plugin/utils';
|
|
5
|
-
import { BuiltinPlugin } from '../builtin-plugin/constructors';
|
|
6
|
-
import { arraify, unsupported } from './misc';
|
|
7
|
-
import { normalizedStringOrRegex } from './normalize-string-or-regex';
|
|
8
|
-
export function bindingifyInputOptions(rawPlugins, inputOptions, outputOptions, onLog, logLevel) {
|
|
9
|
-
const pluginContextData = new PluginContextData();
|
|
10
|
-
const plugins = rawPlugins.map((plugin) => {
|
|
11
|
-
if ('_parallel' in plugin) {
|
|
12
|
-
return undefined;
|
|
13
|
-
}
|
|
14
|
-
if (plugin instanceof BuiltinPlugin) {
|
|
15
|
-
return bindingifyBuiltInPlugin(plugin);
|
|
16
|
-
}
|
|
17
|
-
return bindingifyPlugin(plugin, inputOptions, outputOptions, pluginContextData, onLog, logLevel);
|
|
18
|
-
});
|
|
19
|
-
return {
|
|
20
|
-
input: bindingifyInput(inputOptions.input),
|
|
21
|
-
plugins,
|
|
22
|
-
cwd: inputOptions.cwd ?? process.cwd(),
|
|
23
|
-
external: bindingifyExternal(inputOptions.external),
|
|
24
|
-
resolve: bindingifyResolve(inputOptions.resolve),
|
|
25
|
-
platform: inputOptions.platform,
|
|
26
|
-
shimMissingExports: inputOptions.shimMissingExports,
|
|
27
|
-
logLevel: bindingifyLogLevel(logLevel),
|
|
28
|
-
onLog,
|
|
29
|
-
// After normalized, `false` will be converted to `undefined`, otherwise, default value will be assigned
|
|
30
|
-
// Because it is hard to represent Enum in napi, ref: https://github.com/napi-rs/napi-rs/issues/507
|
|
31
|
-
// So we use `undefined | NormalizedTreeshakingOptions` (or Option<NormalizedTreeshakingOptions> in rust side), to represent `false | NormalizedTreeshakingOptions`
|
|
32
|
-
treeshake: bindingifyTreeshakeOptions(inputOptions.treeshake),
|
|
33
|
-
moduleTypes: inputOptions.moduleTypes,
|
|
34
|
-
define: inputOptions.define
|
|
35
|
-
? Object.entries(inputOptions.define)
|
|
36
|
-
: undefined,
|
|
37
|
-
inject: bindingifyInject(inputOptions.inject),
|
|
38
|
-
experimental: {
|
|
39
|
-
strictExecutionOrder: inputOptions.experimental?.strictExecutionOrder,
|
|
40
|
-
disableLiveBindings: inputOptions.experimental?.disableLiveBindings,
|
|
41
|
-
viteMode: inputOptions.experimental?.viteMode,
|
|
42
|
-
resolveNewUrlToAsset: inputOptions.experimental?.resolveNewUrlToAsset,
|
|
43
|
-
hmr: inputOptions.experimental?.hmr,
|
|
44
|
-
},
|
|
45
|
-
profilerNames: inputOptions?.profilerNames,
|
|
46
|
-
jsx: bindingifyJsx(inputOptions.jsx),
|
|
47
|
-
watch: bindingifyWatch(inputOptions.watch),
|
|
48
|
-
dropLabels: inputOptions.dropLabels,
|
|
49
|
-
keepNames: inputOptions.keepNames,
|
|
50
|
-
checks: inputOptions.checks,
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function bindingifyExternal(external) {
|
|
54
|
-
if (external) {
|
|
55
|
-
if (typeof external === 'function') {
|
|
56
|
-
return (id, importer, isResolved) => {
|
|
57
|
-
if (id.startsWith('\0'))
|
|
58
|
-
return false;
|
|
59
|
-
return external(id, importer, isResolved) ?? false;
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
const externalArr = arraify(external);
|
|
63
|
-
return (id, _importer, _isResolved) => {
|
|
64
|
-
return externalArr.some((pat) => {
|
|
65
|
-
if (pat instanceof RegExp) {
|
|
66
|
-
return pat.test(id);
|
|
67
|
-
}
|
|
68
|
-
return id === pat;
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function bindingifyResolve(resolve) {
|
|
74
|
-
if (resolve) {
|
|
75
|
-
const { alias, extensionAlias, ...rest } = resolve;
|
|
76
|
-
return {
|
|
77
|
-
alias: alias
|
|
78
|
-
? Object.entries(alias).map(([name, replacement]) => ({
|
|
79
|
-
find: name,
|
|
80
|
-
replacements: arraify(replacement),
|
|
81
|
-
}))
|
|
82
|
-
: undefined,
|
|
83
|
-
extensionAlias: extensionAlias
|
|
84
|
-
? Object.entries(extensionAlias).map(([name, value]) => ({
|
|
85
|
-
target: name,
|
|
86
|
-
replacements: value,
|
|
87
|
-
}))
|
|
88
|
-
: undefined,
|
|
89
|
-
...rest,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function bindingifyInject(inject) {
|
|
94
|
-
if (inject) {
|
|
95
|
-
return Object.entries(inject).map(([alias, item]) => {
|
|
96
|
-
if (Array.isArray(item)) {
|
|
97
|
-
// import * as fs from 'node:fs'
|
|
98
|
-
// fs: ['node:fs', '*' ],
|
|
99
|
-
if (item[1] === '*') {
|
|
100
|
-
return {
|
|
101
|
-
tagNamespace: true,
|
|
102
|
-
alias,
|
|
103
|
-
from: item[0],
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
// import { Promise } from 'es6-promise'
|
|
107
|
-
// Promise: [ 'es6-promise', 'Promise' ],
|
|
108
|
-
// import { Promise as P } from 'es6-promise'
|
|
109
|
-
// P: [ 'es6-promise', 'Promise' ],
|
|
110
|
-
return {
|
|
111
|
-
tagNamed: true,
|
|
112
|
-
alias,
|
|
113
|
-
from: item[0],
|
|
114
|
-
imported: item[1],
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
else {
|
|
118
|
-
// import $ from 'jquery'
|
|
119
|
-
// $: 'jquery',
|
|
120
|
-
// 'Object.assign': path.resolve( 'src/helpers/object-assign.js' ),
|
|
121
|
-
return {
|
|
122
|
-
tagNamed: true,
|
|
123
|
-
imported: 'default',
|
|
124
|
-
alias,
|
|
125
|
-
from: item,
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
function bindingifyLogLevel(logLevel) {
|
|
132
|
-
switch (logLevel) {
|
|
133
|
-
case 'silent':
|
|
134
|
-
return BindingLogLevel.Silent;
|
|
135
|
-
case 'debug':
|
|
136
|
-
return BindingLogLevel.Debug;
|
|
137
|
-
case 'warn':
|
|
138
|
-
return BindingLogLevel.Warn;
|
|
139
|
-
case 'info':
|
|
140
|
-
return BindingLogLevel.Info;
|
|
141
|
-
default:
|
|
142
|
-
throw new Error(`Unexpected log level: ${logLevel}`);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
function bindingifyInput(input) {
|
|
146
|
-
if (input === undefined) {
|
|
147
|
-
return [];
|
|
148
|
-
}
|
|
149
|
-
if (typeof input === 'string') {
|
|
150
|
-
return [{ import: input }];
|
|
151
|
-
}
|
|
152
|
-
if (Array.isArray(input)) {
|
|
153
|
-
return input.map((src) => ({ import: src }));
|
|
154
|
-
}
|
|
155
|
-
return Object.entries(input).map((value) => {
|
|
156
|
-
return { name: value[0], import: value[1] };
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
// The `automatic` is most user usages, so it is different rollup's default value `false`
|
|
160
|
-
function bindingifyJsx(input) {
|
|
161
|
-
if (input === false) {
|
|
162
|
-
return { type: 'Disable' };
|
|
163
|
-
}
|
|
164
|
-
if (input) {
|
|
165
|
-
if (input.mode === 'preserve') {
|
|
166
|
-
return { type: 'Preserve' };
|
|
167
|
-
}
|
|
168
|
-
const mode = input.mode ?? 'automatic';
|
|
169
|
-
return {
|
|
170
|
-
type: 'Enable',
|
|
171
|
-
field0: {
|
|
172
|
-
runtime: mode,
|
|
173
|
-
importSource: mode === 'classic'
|
|
174
|
-
? input.importSource
|
|
175
|
-
: mode === 'automatic'
|
|
176
|
-
? input.jsxImportSource
|
|
177
|
-
: undefined,
|
|
178
|
-
pragma: input.factory,
|
|
179
|
-
pragmaFrag: input.fragment,
|
|
180
|
-
development: input.development,
|
|
181
|
-
refresh: input.refresh,
|
|
182
|
-
},
|
|
183
|
-
};
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
function bindingifyWatch(watch) {
|
|
187
|
-
if (watch) {
|
|
188
|
-
let value = {
|
|
189
|
-
skipWrite: watch.skipWrite,
|
|
190
|
-
include: normalizedStringOrRegex(watch.include),
|
|
191
|
-
exclude: normalizedStringOrRegex(watch.exclude),
|
|
192
|
-
};
|
|
193
|
-
if (watch.chokidar) {
|
|
194
|
-
unsupported('The watch chokidar option is deprecated, please use notify options instead of it.');
|
|
195
|
-
}
|
|
196
|
-
return value;
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
function bindingifyTreeshakeOptions(config) {
|
|
200
|
-
if (config === false) {
|
|
201
|
-
return undefined;
|
|
202
|
-
}
|
|
203
|
-
if (config === true || config === undefined) {
|
|
204
|
-
return {
|
|
205
|
-
moduleSideEffects: true,
|
|
206
|
-
annotations: true,
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
let normalizedConfig = {
|
|
210
|
-
moduleSideEffects: true,
|
|
211
|
-
};
|
|
212
|
-
if (config.moduleSideEffects === undefined) {
|
|
213
|
-
normalizedConfig.moduleSideEffects = true;
|
|
214
|
-
}
|
|
215
|
-
else if (config.moduleSideEffects === 'no-external') {
|
|
216
|
-
normalizedConfig.moduleSideEffects = [
|
|
217
|
-
{ external: true, sideEffects: false },
|
|
218
|
-
{ external: false, sideEffects: true },
|
|
219
|
-
];
|
|
220
|
-
}
|
|
221
|
-
else {
|
|
222
|
-
normalizedConfig.moduleSideEffects = config.moduleSideEffects;
|
|
223
|
-
}
|
|
224
|
-
normalizedConfig.annotations = config.annotations ?? true;
|
|
225
|
-
return normalizedConfig;
|
|
226
|
-
}
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { unimplemented } from './misc';
|
|
2
|
-
import { transformRenderedChunk } from './transform-rendered-chunk';
|
|
3
|
-
import { transformAssetSource } from './asset-source';
|
|
4
|
-
export function bindingifyOutputOptions(outputOptions) {
|
|
5
|
-
const { dir, format, exports, hashCharacters, sourcemap, sourcemapIgnoreList, sourcemapPathTransform, name, assetFileNames, entryFileNames, chunkFileNames, cssEntryFileNames, cssChunkFileNames, banner, footer, intro, outro, esModule, globals, file, sanitizeFileName, } = outputOptions;
|
|
6
|
-
return {
|
|
7
|
-
dir,
|
|
8
|
-
// Handle case: rollup/test/sourcemaps/samples/sourcemap-file-hashed/_config.js
|
|
9
|
-
file: file == null ? undefined : file,
|
|
10
|
-
format: bindingifyFormat(format),
|
|
11
|
-
exports,
|
|
12
|
-
hashCharacters,
|
|
13
|
-
sourcemap: bindingifySourcemap(sourcemap),
|
|
14
|
-
sourcemapIgnoreList: bindingifySourcemapIgnoreList(sourcemapIgnoreList),
|
|
15
|
-
sourcemapPathTransform,
|
|
16
|
-
banner: bindingifyAddon(banner),
|
|
17
|
-
footer: bindingifyAddon(footer),
|
|
18
|
-
intro: bindingifyAddon(intro),
|
|
19
|
-
outro: bindingifyAddon(outro),
|
|
20
|
-
extend: outputOptions.extend,
|
|
21
|
-
globals,
|
|
22
|
-
esModule,
|
|
23
|
-
name,
|
|
24
|
-
assetFileNames: bindingifyAssetFilenames(assetFileNames),
|
|
25
|
-
entryFileNames,
|
|
26
|
-
chunkFileNames,
|
|
27
|
-
cssEntryFileNames,
|
|
28
|
-
cssChunkFileNames,
|
|
29
|
-
// TODO(sapphi-red): support parallel plugins
|
|
30
|
-
plugins: [],
|
|
31
|
-
minify: outputOptions.minify,
|
|
32
|
-
externalLiveBindings: outputOptions.externalLiveBindings,
|
|
33
|
-
inlineDynamicImports: outputOptions.inlineDynamicImports,
|
|
34
|
-
advancedChunks: outputOptions.advancedChunks,
|
|
35
|
-
polyfillRequire: outputOptions.polyfillRequire,
|
|
36
|
-
target: outputOptions.target,
|
|
37
|
-
sanitizeFileName,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
40
|
-
function bindingifyAddon(configAddon) {
|
|
41
|
-
return async (chunk) => {
|
|
42
|
-
if (typeof configAddon === 'function') {
|
|
43
|
-
return configAddon(transformRenderedChunk(chunk));
|
|
44
|
-
}
|
|
45
|
-
return configAddon || '';
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
function bindingifyFormat(format) {
|
|
49
|
-
switch (format) {
|
|
50
|
-
case undefined:
|
|
51
|
-
case 'es':
|
|
52
|
-
case 'esm':
|
|
53
|
-
case 'module': {
|
|
54
|
-
return 'es';
|
|
55
|
-
}
|
|
56
|
-
case 'cjs':
|
|
57
|
-
case 'commonjs': {
|
|
58
|
-
return 'cjs';
|
|
59
|
-
}
|
|
60
|
-
case 'iife': {
|
|
61
|
-
return 'iife';
|
|
62
|
-
}
|
|
63
|
-
case 'umd': {
|
|
64
|
-
return 'umd';
|
|
65
|
-
}
|
|
66
|
-
case 'experimental-app': {
|
|
67
|
-
return 'app';
|
|
68
|
-
}
|
|
69
|
-
default:
|
|
70
|
-
unimplemented(`output.format: ${format}`);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
function bindingifySourcemap(sourcemap) {
|
|
74
|
-
switch (sourcemap) {
|
|
75
|
-
case true:
|
|
76
|
-
return 'file';
|
|
77
|
-
case 'inline':
|
|
78
|
-
return 'inline';
|
|
79
|
-
case false:
|
|
80
|
-
case undefined:
|
|
81
|
-
return undefined;
|
|
82
|
-
case 'hidden':
|
|
83
|
-
return 'hidden';
|
|
84
|
-
default:
|
|
85
|
-
throw new Error(`unknown sourcemap: ${sourcemap}`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
function bindingifySourcemapIgnoreList(sourcemapIgnoreList) {
|
|
89
|
-
return typeof sourcemapIgnoreList === 'function'
|
|
90
|
-
? sourcemapIgnoreList
|
|
91
|
-
: sourcemapIgnoreList === false
|
|
92
|
-
? () => false
|
|
93
|
-
: (relativeSourcePath, _sourcemapPath) => relativeSourcePath.includes('node_modules');
|
|
94
|
-
}
|
|
95
|
-
function bindingifyAssetFilenames(assetFileNames) {
|
|
96
|
-
if (typeof assetFileNames === 'function') {
|
|
97
|
-
return (asset) => {
|
|
98
|
-
return assetFileNames({
|
|
99
|
-
names: asset.names,
|
|
100
|
-
originalFileNames: asset.originalFileNames,
|
|
101
|
-
source: transformAssetSource(asset.source),
|
|
102
|
-
type: 'asset',
|
|
103
|
-
});
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
return assetFileNames;
|
|
107
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
function spaces(index) {
|
|
2
|
-
let result = '';
|
|
3
|
-
while (index--)
|
|
4
|
-
result += ' ';
|
|
5
|
-
return result;
|
|
6
|
-
}
|
|
7
|
-
function tabsToSpaces(value) {
|
|
8
|
-
return value.replace(/^\t+/, (match) => match.split('\t').join(' '));
|
|
9
|
-
}
|
|
10
|
-
const LINE_TRUNCATE_LENGTH = 120;
|
|
11
|
-
const MIN_CHARACTERS_SHOWN_AFTER_LOCATION = 10;
|
|
12
|
-
const ELLIPSIS = '...';
|
|
13
|
-
export function getCodeFrame(source, line, column) {
|
|
14
|
-
let lines = source.split('\n');
|
|
15
|
-
// Needed if a plugin did not generate correct sourcemaps
|
|
16
|
-
if (line > lines.length)
|
|
17
|
-
return '';
|
|
18
|
-
const maxLineLength = Math.max(tabsToSpaces(lines[line - 1].slice(0, column)).length +
|
|
19
|
-
MIN_CHARACTERS_SHOWN_AFTER_LOCATION +
|
|
20
|
-
ELLIPSIS.length, LINE_TRUNCATE_LENGTH);
|
|
21
|
-
const frameStart = Math.max(0, line - 3);
|
|
22
|
-
let frameEnd = Math.min(line + 2, lines.length);
|
|
23
|
-
lines = lines.slice(frameStart, frameEnd);
|
|
24
|
-
while (!/\S/.test(lines[lines.length - 1])) {
|
|
25
|
-
lines.pop();
|
|
26
|
-
frameEnd -= 1;
|
|
27
|
-
}
|
|
28
|
-
const digits = String(frameEnd).length;
|
|
29
|
-
return lines
|
|
30
|
-
.map((sourceLine, index) => {
|
|
31
|
-
const isErrorLine = frameStart + index + 1 === line;
|
|
32
|
-
let lineNumber = String(index + frameStart + 1);
|
|
33
|
-
while (lineNumber.length < digits)
|
|
34
|
-
lineNumber = ` ${lineNumber}`;
|
|
35
|
-
let displayedLine = tabsToSpaces(sourceLine);
|
|
36
|
-
if (displayedLine.length > maxLineLength) {
|
|
37
|
-
displayedLine = `${displayedLine.slice(0, maxLineLength - ELLIPSIS.length)}${ELLIPSIS}`;
|
|
38
|
-
}
|
|
39
|
-
if (isErrorLine) {
|
|
40
|
-
const indicator = spaces(digits + 2 + tabsToSpaces(sourceLine.slice(0, column)).length) + '^';
|
|
41
|
-
return `${lineNumber}: ${displayedLine}\n${indicator}`;
|
|
42
|
-
}
|
|
43
|
-
return `${lineNumber}: ${displayedLine}`;
|
|
44
|
-
})
|
|
45
|
-
.join('\n');
|
|
46
|
-
}
|