rolldown 1.0.0-beta.3-commit.306867e → 1.0.0-beta.3-commit.558ea78
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 +1 -1
- package/dist/cjs/experimental-index.cjs +1 -1
- package/dist/cjs/index.cjs +1 -1
- package/dist/cjs/parallel-plugin-worker.cjs +1 -1
- package/dist/esm/cli.mjs +1 -1
- package/dist/esm/experimental-index.mjs +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/parallel-plugin-worker.mjs +1 -1
- package/dist/shared/{src-BGJCTYiA.mjs → src-Cis0qYEg.mjs} +33 -13
- package/dist/shared/{src-BL6ftzBh.cjs → src-Z84gVvFu.cjs} +33 -13
- package/dist/types/index.d.ts +3 -3
- package/dist/types/log/logging.d.ts +1 -0
- package/dist/types/options/input-options.d.ts +2 -2
- package/dist/types/plugin/plugin-context-data.d.ts +2 -1
- package/package.json +14 -14
- 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,124 +0,0 @@
|
|
|
1
|
-
import { bindingifyBuildEnd, bindingifyBuildStart, bindingifyLoad, bindingifyModuleParsed, bindingifyResolveDynamicImport, bindingifyResolveId, bindingifyTransform, } from './bindingify-build-hooks';
|
|
2
|
-
import { bindingifyRenderStart, bindingifyRenderChunk, bindingifyGenerateBundle, bindingifyWriteBundle, bindingifyRenderError, bindingifyAugmentChunkHash, bindingifyBanner, bindingifyFooter, bindingifyIntro, bindingifyOutro, bindingifyCloseBundle, } from './bindingify-output-hooks';
|
|
3
|
-
import { bindingifyCloseWatcher, bindingifyWatchChange, } from './bindingify-watch-hooks';
|
|
4
|
-
import { error, logPluginError } from '../log/logs';
|
|
5
|
-
// Note: because napi not catch error, so we need to catch error and print error to debugger in adapter.
|
|
6
|
-
export function bindingifyPlugin(plugin, options, outputOptions, pluginContextData, onLog, logLevel) {
|
|
7
|
-
const args = {
|
|
8
|
-
plugin,
|
|
9
|
-
options,
|
|
10
|
-
outputOptions,
|
|
11
|
-
pluginContextData,
|
|
12
|
-
onLog,
|
|
13
|
-
logLevel,
|
|
14
|
-
};
|
|
15
|
-
const { plugin: buildStart, meta: buildStartMeta } = bindingifyBuildStart(args);
|
|
16
|
-
const { plugin: resolveId, meta: resolveIdMeta, filter: resolveIdFilter, } = bindingifyResolveId(args);
|
|
17
|
-
const { plugin: resolveDynamicImport, meta: resolveDynamicImportMeta } = bindingifyResolveDynamicImport(args);
|
|
18
|
-
const { plugin: buildEnd, meta: buildEndMeta } = bindingifyBuildEnd(args);
|
|
19
|
-
const { plugin: transform, meta: transformMeta, filter: transformFilter, } = bindingifyTransform(args);
|
|
20
|
-
const { plugin: moduleParsed, meta: moduleParsedMeta } = bindingifyModuleParsed(args);
|
|
21
|
-
const { plugin: load, meta: loadMeta, filter: loadFilter, } = bindingifyLoad(args);
|
|
22
|
-
const { plugin: renderChunk, meta: renderChunkMeta } = bindingifyRenderChunk(args);
|
|
23
|
-
const { plugin: augmentChunkHash, meta: augmentChunkHashMeta } = bindingifyAugmentChunkHash(args);
|
|
24
|
-
const { plugin: renderStart, meta: renderStartMeta } = bindingifyRenderStart(args);
|
|
25
|
-
const { plugin: renderError, meta: renderErrorMeta } = bindingifyRenderError(args);
|
|
26
|
-
const { plugin: generateBundle, meta: generateBundleMeta } = bindingifyGenerateBundle(args);
|
|
27
|
-
const { plugin: writeBundle, meta: writeBundleMeta } = bindingifyWriteBundle(args);
|
|
28
|
-
const { plugin: closeBundle, meta: closeBundleMeta } = bindingifyCloseBundle(args);
|
|
29
|
-
const { plugin: banner, meta: bannerMeta } = bindingifyBanner(args);
|
|
30
|
-
const { plugin: footer, meta: footerMeta } = bindingifyFooter(args);
|
|
31
|
-
const { plugin: intro, meta: introMeta } = bindingifyIntro(args);
|
|
32
|
-
const { plugin: outro, meta: outroMeta } = bindingifyOutro(args);
|
|
33
|
-
const { plugin: watchChange, meta: watchChangeMeta } = bindingifyWatchChange(args);
|
|
34
|
-
const { plugin: closeWatcher, meta: closeWatcherMeta } = bindingifyCloseWatcher(args);
|
|
35
|
-
const result = {
|
|
36
|
-
// The plugin name already normalized at `normalizePlugins`, see `packages/rolldown/src/utils/normalize-plugin-option.ts`
|
|
37
|
-
name: plugin.name,
|
|
38
|
-
buildStart,
|
|
39
|
-
buildStartMeta,
|
|
40
|
-
resolveId,
|
|
41
|
-
resolveIdMeta,
|
|
42
|
-
// @ts-ignore
|
|
43
|
-
resolveIdFilter,
|
|
44
|
-
resolveDynamicImport,
|
|
45
|
-
resolveDynamicImportMeta,
|
|
46
|
-
buildEnd,
|
|
47
|
-
buildEndMeta,
|
|
48
|
-
transform,
|
|
49
|
-
transformMeta,
|
|
50
|
-
transformFilter,
|
|
51
|
-
moduleParsed,
|
|
52
|
-
moduleParsedMeta,
|
|
53
|
-
load,
|
|
54
|
-
loadMeta,
|
|
55
|
-
loadFilter,
|
|
56
|
-
renderChunk,
|
|
57
|
-
renderChunkMeta,
|
|
58
|
-
augmentChunkHash,
|
|
59
|
-
augmentChunkHashMeta,
|
|
60
|
-
renderStart,
|
|
61
|
-
renderStartMeta,
|
|
62
|
-
renderError,
|
|
63
|
-
renderErrorMeta,
|
|
64
|
-
generateBundle,
|
|
65
|
-
generateBundleMeta,
|
|
66
|
-
writeBundle,
|
|
67
|
-
writeBundleMeta,
|
|
68
|
-
closeBundle,
|
|
69
|
-
closeBundleMeta,
|
|
70
|
-
banner,
|
|
71
|
-
bannerMeta,
|
|
72
|
-
footer,
|
|
73
|
-
footerMeta,
|
|
74
|
-
intro,
|
|
75
|
-
introMeta,
|
|
76
|
-
outro,
|
|
77
|
-
outroMeta,
|
|
78
|
-
watchChange,
|
|
79
|
-
watchChangeMeta,
|
|
80
|
-
closeWatcher,
|
|
81
|
-
closeWatcherMeta,
|
|
82
|
-
};
|
|
83
|
-
return wrapHandlers(result);
|
|
84
|
-
}
|
|
85
|
-
function wrapHandlers(plugin) {
|
|
86
|
-
for (const hookName of [
|
|
87
|
-
'buildStart',
|
|
88
|
-
'resolveId',
|
|
89
|
-
'resolveDynamicImport',
|
|
90
|
-
'buildEnd',
|
|
91
|
-
'transform',
|
|
92
|
-
'moduleParsed',
|
|
93
|
-
'load',
|
|
94
|
-
'renderChunk',
|
|
95
|
-
'augmentChunkHash',
|
|
96
|
-
'renderStart',
|
|
97
|
-
'renderError',
|
|
98
|
-
'generateBundle',
|
|
99
|
-
'writeBundle',
|
|
100
|
-
'closeBundle',
|
|
101
|
-
'banner',
|
|
102
|
-
'footer',
|
|
103
|
-
'intro',
|
|
104
|
-
'outro',
|
|
105
|
-
'watchChange',
|
|
106
|
-
'closeWatcher',
|
|
107
|
-
]) {
|
|
108
|
-
const handler = plugin[hookName];
|
|
109
|
-
if (handler) {
|
|
110
|
-
plugin[hookName] = async (...args) => {
|
|
111
|
-
try {
|
|
112
|
-
return await handler(...args);
|
|
113
|
-
}
|
|
114
|
-
catch (e) {
|
|
115
|
-
return error(logPluginError(e, plugin.name, {
|
|
116
|
-
hook: hookName,
|
|
117
|
-
id: hookName === 'transform' ? args[2] : undefined,
|
|
118
|
-
}));
|
|
119
|
-
}
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return plugin;
|
|
124
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { normalizeHook } from '../utils/normalize-hook';
|
|
2
|
-
import { PluginContext } from './plugin-context';
|
|
3
|
-
import { bindingifyPluginHookMeta, } from './bindingify-plugin-hook-meta';
|
|
4
|
-
export function bindingifyWatchChange(args) {
|
|
5
|
-
const hook = args.plugin.watchChange;
|
|
6
|
-
if (!hook) {
|
|
7
|
-
return {};
|
|
8
|
-
}
|
|
9
|
-
const { handler, meta } = normalizeHook(hook);
|
|
10
|
-
return {
|
|
11
|
-
plugin: async (ctx, id, event) => {
|
|
12
|
-
await handler.call(new PluginContext(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel), id, { event: event });
|
|
13
|
-
},
|
|
14
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export function bindingifyCloseWatcher(args) {
|
|
18
|
-
const hook = args.plugin.closeWatcher;
|
|
19
|
-
if (!hook) {
|
|
20
|
-
return {};
|
|
21
|
-
}
|
|
22
|
-
const { handler, meta } = normalizeHook(hook);
|
|
23
|
-
return {
|
|
24
|
-
plugin: async (ctx) => {
|
|
25
|
-
await handler.call(new PluginContext(args.outputOptions, ctx, args.plugin, args.pluginContextData, args.onLog, args.logLevel));
|
|
26
|
-
},
|
|
27
|
-
meta: bindingifyPluginHookMeta(meta),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_WARN } from '../log/logging';
|
|
2
|
-
import { error, logPluginError } from '../log/logs';
|
|
3
|
-
import { getLogHandler, normalizeLog } from '../log/logHandler';
|
|
4
|
-
import { VERSION } from '..';
|
|
5
|
-
export class MinimalPluginContext {
|
|
6
|
-
pluginName;
|
|
7
|
-
info;
|
|
8
|
-
warn;
|
|
9
|
-
debug;
|
|
10
|
-
meta;
|
|
11
|
-
constructor(onLog, logLevel, pluginName) {
|
|
12
|
-
this.pluginName = pluginName;
|
|
13
|
-
this.debug = getLogHandler(LOG_LEVEL_DEBUG, 'PLUGIN_LOG', onLog, pluginName, logLevel);
|
|
14
|
-
this.info = getLogHandler(LOG_LEVEL_INFO, 'PLUGIN_LOG', onLog, pluginName, logLevel);
|
|
15
|
-
this.warn = getLogHandler(LOG_LEVEL_WARN, 'PLUGIN_WARNING', onLog, pluginName, logLevel);
|
|
16
|
-
this.meta = {
|
|
17
|
-
rollupVersion: '4.23.0',
|
|
18
|
-
rolldownVersion: VERSION,
|
|
19
|
-
watchMode: false,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
error(e) {
|
|
23
|
-
return error(logPluginError(normalizeLog(e), this.pluginName));
|
|
24
|
-
}
|
|
25
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { transformModuleInfo } from '../utils/transform-module-info';
|
|
2
|
-
export class PluginContextData {
|
|
3
|
-
moduleOptionMap = new Map();
|
|
4
|
-
resolveOptionsMap = new Map();
|
|
5
|
-
loadModulePromiseMap = new Map();
|
|
6
|
-
updateModuleOption(id, option) {
|
|
7
|
-
const existing = this.moduleOptionMap.get(id);
|
|
8
|
-
if (existing) {
|
|
9
|
-
if (option.moduleSideEffects != null) {
|
|
10
|
-
existing.moduleSideEffects = option.moduleSideEffects;
|
|
11
|
-
}
|
|
12
|
-
if (option.meta != null) {
|
|
13
|
-
Object.assign(existing.meta, option.meta);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
else {
|
|
17
|
-
this.moduleOptionMap.set(id, option);
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
getModuleOption(id) {
|
|
21
|
-
const option = this.moduleOptionMap.get(id);
|
|
22
|
-
if (!option) {
|
|
23
|
-
const raw = {
|
|
24
|
-
moduleSideEffects: null,
|
|
25
|
-
meta: {},
|
|
26
|
-
};
|
|
27
|
-
this.moduleOptionMap.set(id, raw);
|
|
28
|
-
return raw;
|
|
29
|
-
}
|
|
30
|
-
return option;
|
|
31
|
-
}
|
|
32
|
-
getModuleInfo(id, context) {
|
|
33
|
-
const bindingInfo = context.getModuleInfo(id);
|
|
34
|
-
if (bindingInfo) {
|
|
35
|
-
const info = transformModuleInfo(bindingInfo, this.getModuleOption(id));
|
|
36
|
-
return info;
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
getModuleIds(context) {
|
|
41
|
-
const moduleIds = context.getModuleIds();
|
|
42
|
-
return moduleIds.values();
|
|
43
|
-
}
|
|
44
|
-
saveResolveOptions(options) {
|
|
45
|
-
const index = this.resolveOptionsMap.size;
|
|
46
|
-
this.resolveOptionsMap.set(index, options);
|
|
47
|
-
return index;
|
|
48
|
-
}
|
|
49
|
-
getSavedResolveOptions(receipt) {
|
|
50
|
-
return this.resolveOptionsMap.get(receipt);
|
|
51
|
-
}
|
|
52
|
-
removeSavedResolveOptions(receipt) {
|
|
53
|
-
this.resolveOptionsMap.delete(receipt);
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { MinimalPluginContext } from '../plugin/minimal-plugin-context';
|
|
2
|
-
import { bindingAssetSource } from '../utils/asset-source';
|
|
3
|
-
import { unimplemented, unsupported } from '../utils/misc';
|
|
4
|
-
import { SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF } from '../constants/plugin-context';
|
|
5
|
-
import { bindingifySideEffects } from '../utils/transform-side-effects';
|
|
6
|
-
import { LOG_LEVEL_WARN } from '../log/logging';
|
|
7
|
-
import { logCycleLoading } from '../log/logs';
|
|
8
|
-
export class PluginContext extends MinimalPluginContext {
|
|
9
|
-
outputOptions;
|
|
10
|
-
context;
|
|
11
|
-
data;
|
|
12
|
-
onLog;
|
|
13
|
-
currentLoadingModule;
|
|
14
|
-
constructor(outputOptions, context, plugin, data, onLog, logLevel, currentLoadingModule) {
|
|
15
|
-
super(onLog, logLevel, plugin.name);
|
|
16
|
-
this.outputOptions = outputOptions;
|
|
17
|
-
this.context = context;
|
|
18
|
-
this.data = data;
|
|
19
|
-
this.onLog = onLog;
|
|
20
|
-
this.currentLoadingModule = currentLoadingModule;
|
|
21
|
-
}
|
|
22
|
-
async load(options) {
|
|
23
|
-
const id = options.id;
|
|
24
|
-
if (id === this.currentLoadingModule) {
|
|
25
|
-
this.onLog(LOG_LEVEL_WARN, logCycleLoading(this.pluginName, this.currentLoadingModule));
|
|
26
|
-
}
|
|
27
|
-
// resolveDependencies always true at rolldown
|
|
28
|
-
const moduleInfo = this.data.getModuleInfo(id, this.context);
|
|
29
|
-
if (moduleInfo && moduleInfo.code !== null /* module already parsed */) {
|
|
30
|
-
return moduleInfo;
|
|
31
|
-
}
|
|
32
|
-
const rawOptions = {
|
|
33
|
-
meta: options.meta || {},
|
|
34
|
-
moduleSideEffects: options.moduleSideEffects || null,
|
|
35
|
-
};
|
|
36
|
-
this.data.updateModuleOption(id, rawOptions);
|
|
37
|
-
async function createLoadModulePromise(context, data) {
|
|
38
|
-
const loadPromise = data.loadModulePromiseMap.get(id);
|
|
39
|
-
if (loadPromise) {
|
|
40
|
-
return loadPromise;
|
|
41
|
-
}
|
|
42
|
-
let resolveFn;
|
|
43
|
-
// TODO: If is not resolved, we need to set a time to avoid waiting.
|
|
44
|
-
const promise = new Promise((resolve, _) => {
|
|
45
|
-
resolveFn = resolve;
|
|
46
|
-
});
|
|
47
|
-
data.loadModulePromiseMap.set(id, promise);
|
|
48
|
-
try {
|
|
49
|
-
await context.load(id, bindingifySideEffects(options.moduleSideEffects), resolveFn);
|
|
50
|
-
}
|
|
51
|
-
finally {
|
|
52
|
-
// If the load module has failed, avoid it re-load using unresolved promise.
|
|
53
|
-
data.loadModulePromiseMap.delete(id);
|
|
54
|
-
}
|
|
55
|
-
return promise;
|
|
56
|
-
}
|
|
57
|
-
// Here using one promise to avoid pass more callback to rust side, it only accept one callback, other will be ignored.
|
|
58
|
-
await createLoadModulePromise(this.context, this.data);
|
|
59
|
-
return this.data.getModuleInfo(id, this.context);
|
|
60
|
-
}
|
|
61
|
-
async resolve(source, importer, options) {
|
|
62
|
-
let receipt = undefined;
|
|
63
|
-
if (options != null) {
|
|
64
|
-
receipt = this.data.saveResolveOptions(options);
|
|
65
|
-
}
|
|
66
|
-
const res = await this.context.resolve(source, importer, {
|
|
67
|
-
custom: receipt,
|
|
68
|
-
skipSelf: options?.skipSelf,
|
|
69
|
-
});
|
|
70
|
-
if (receipt != null) {
|
|
71
|
-
this.data.removeSavedResolveOptions(receipt);
|
|
72
|
-
}
|
|
73
|
-
if (res == null)
|
|
74
|
-
return null;
|
|
75
|
-
const info = this.data.getModuleOption(res.id) || {};
|
|
76
|
-
return { ...res, ...info };
|
|
77
|
-
}
|
|
78
|
-
emitFile(file) {
|
|
79
|
-
// @ts-expect-error
|
|
80
|
-
if (file.type === 'prebuilt-chunk') {
|
|
81
|
-
return unimplemented('PluginContext.emitFile with type prebuilt-chunk');
|
|
82
|
-
}
|
|
83
|
-
if (file.type === 'chunk') {
|
|
84
|
-
return this.context.emitChunk(file);
|
|
85
|
-
}
|
|
86
|
-
const fnSanitizedFileName = file.fileName || typeof this.outputOptions.sanitizeFileName !== 'function'
|
|
87
|
-
? undefined
|
|
88
|
-
: this.outputOptions.sanitizeFileName(file.name || 'asset');
|
|
89
|
-
const filename = file.fileName ? undefined : this.getAssetFileNames(file);
|
|
90
|
-
return this.context.emitFile({
|
|
91
|
-
...file,
|
|
92
|
-
originalFileName: file.originalFileName || undefined,
|
|
93
|
-
source: bindingAssetSource(file.source),
|
|
94
|
-
}, filename, fnSanitizedFileName);
|
|
95
|
-
}
|
|
96
|
-
getAssetFileNames(file) {
|
|
97
|
-
if (typeof this.outputOptions.assetFileNames === 'function') {
|
|
98
|
-
return this.outputOptions.assetFileNames({
|
|
99
|
-
names: file.name ? [file.name] : [],
|
|
100
|
-
originalFileNames: file.originalFileName ? [file.originalFileName] : [],
|
|
101
|
-
source: file.source,
|
|
102
|
-
type: 'asset',
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
getFileName(referenceId) {
|
|
107
|
-
return this.context.getFileName(referenceId);
|
|
108
|
-
}
|
|
109
|
-
getModuleInfo(id) {
|
|
110
|
-
return this.data.getModuleInfo(id, this.context);
|
|
111
|
-
}
|
|
112
|
-
getModuleIds() {
|
|
113
|
-
return this.data.getModuleIds(this.context);
|
|
114
|
-
}
|
|
115
|
-
addWatchFile(id) {
|
|
116
|
-
this.context.addWatchFile(id);
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* @deprecated This rollup API won't be supported by rolldown. Using this API will cause runtime error.
|
|
120
|
-
*/
|
|
121
|
-
parse(_input, _options) {
|
|
122
|
-
unsupported('`PluginContext#parse` is not supported by rolldown.');
|
|
123
|
-
}
|
|
124
|
-
}
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
import { getLogHandler, normalizeLog } from '../log/logHandler';
|
|
2
|
-
import { LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_WARN } from '../log/logging';
|
|
3
|
-
import { error, logPluginError } from '../log/logs';
|
|
4
|
-
import { normalizeHook } from '../utils/normalize-hook';
|
|
5
|
-
import { VERSION } from '..';
|
|
6
|
-
import { getLogger, getOnLog } from '../log/logger';
|
|
7
|
-
import { BuiltinPlugin } from '../builtin-plugin/constructors';
|
|
8
|
-
import { normalizePluginOption } from '../utils/normalize-plugin-option';
|
|
9
|
-
export class PluginDriver {
|
|
10
|
-
static async callOptionsHook(inputOptions) {
|
|
11
|
-
const logLevel = inputOptions.logLevel || LOG_LEVEL_INFO;
|
|
12
|
-
const plugins = getSortedPlugins('options', getObjectPlugins(await normalizePluginOption(inputOptions.plugins)));
|
|
13
|
-
const logger = getLogger(plugins, getOnLog(inputOptions, logLevel), logLevel);
|
|
14
|
-
for (const plugin of plugins) {
|
|
15
|
-
const name = plugin.name || 'unknown';
|
|
16
|
-
const options = plugin.options;
|
|
17
|
-
if (options) {
|
|
18
|
-
const { handler } = normalizeHook(options);
|
|
19
|
-
const result = await handler.call({
|
|
20
|
-
debug: getLogHandler(LOG_LEVEL_DEBUG, 'PLUGIN_LOG', logger, name, logLevel),
|
|
21
|
-
error: (e) => error(logPluginError(normalizeLog(e), name, { hook: 'onLog' })),
|
|
22
|
-
info: getLogHandler(LOG_LEVEL_INFO, 'PLUGIN_LOG', logger, name, logLevel),
|
|
23
|
-
meta: {
|
|
24
|
-
rollupVersion: '4.23.0',
|
|
25
|
-
rolldownVersion: VERSION,
|
|
26
|
-
watchMode: false,
|
|
27
|
-
},
|
|
28
|
-
warn: getLogHandler(LOG_LEVEL_WARN, 'PLUGIN_WARNING', logger, name, logLevel),
|
|
29
|
-
pluginName: name,
|
|
30
|
-
}, inputOptions);
|
|
31
|
-
if (result) {
|
|
32
|
-
inputOptions = result;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return inputOptions;
|
|
37
|
-
}
|
|
38
|
-
static callOutputOptionsHook(rawPlugins, outputOptions) {
|
|
39
|
-
const sortedPlugins = getSortedPlugins('outputOptions', getObjectPlugins(rawPlugins));
|
|
40
|
-
for (const plugin of sortedPlugins) {
|
|
41
|
-
const options = plugin.outputOptions;
|
|
42
|
-
if (options) {
|
|
43
|
-
const { handler } = normalizeHook(options);
|
|
44
|
-
const result = handler.call(null, outputOptions);
|
|
45
|
-
if (result) {
|
|
46
|
-
outputOptions = result;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
return outputOptions;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
export function getObjectPlugins(plugins) {
|
|
54
|
-
return plugins.filter((plugin) => {
|
|
55
|
-
if (!plugin) {
|
|
56
|
-
return undefined;
|
|
57
|
-
}
|
|
58
|
-
if ('_parallel' in plugin) {
|
|
59
|
-
return undefined;
|
|
60
|
-
}
|
|
61
|
-
if (plugin instanceof BuiltinPlugin) {
|
|
62
|
-
return undefined;
|
|
63
|
-
}
|
|
64
|
-
return plugin;
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
export function getSortedPlugins(hookName, plugins) {
|
|
68
|
-
const pre = [];
|
|
69
|
-
const normal = [];
|
|
70
|
-
const post = [];
|
|
71
|
-
for (const plugin of plugins) {
|
|
72
|
-
const hook = plugin[hookName];
|
|
73
|
-
if (hook) {
|
|
74
|
-
if (typeof hook === 'object') {
|
|
75
|
-
if (hook.order === 'pre') {
|
|
76
|
-
pre.push(plugin);
|
|
77
|
-
continue;
|
|
78
|
-
}
|
|
79
|
-
if (hook.order === 'post') {
|
|
80
|
-
post.push(plugin);
|
|
81
|
-
continue;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
normal.push(plugin);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
return [...pre, ...normal, ...post];
|
|
88
|
-
}
|
|
@@ -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
|
-
}
|