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,88 +0,0 @@
|
|
|
1
|
-
import { logger } from '../logger';
|
|
2
|
-
import { version, description, } from '../../../package.json' assert { type: 'json' };
|
|
3
|
-
import { colors } from '../colors';
|
|
4
|
-
import { options } from '../arguments';
|
|
5
|
-
import { camelCaseToKebabCase } from '../arguments/utils';
|
|
6
|
-
const introduction = `${colors.gray(`${description} (rolldown v${version})`)}
|
|
7
|
-
|
|
8
|
-
${colors.bold(colors.underline('USAGE'))} ${colors.cyan('rolldown -c <config>')} or ${colors.cyan('rolldown <input> <options>')}`;
|
|
9
|
-
const examples = [
|
|
10
|
-
{
|
|
11
|
-
title: 'Bundle with a config file `rolldown.config.mjs`',
|
|
12
|
-
command: 'rolldown -c rolldown.config.mjs',
|
|
13
|
-
},
|
|
14
|
-
{
|
|
15
|
-
title: 'Bundle the `src/main.ts` to `dist` with `cjs` format',
|
|
16
|
-
command: 'rolldown src/main.ts -d dist -f cjs',
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
title: 'Bundle the `src/main.ts` and handle the `.png` assets to Data URL',
|
|
20
|
-
command: 'rolldown src/main.ts -d dist --moduleTypes .png=dataurl',
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
title: 'Bundle the `src/main.tsx` and minify the output with sourcemap',
|
|
24
|
-
command: 'rolldown src/main.tsx -d dist -m -s',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
title: 'Create self-executing IIFE using external jQuery as `$` and `_`',
|
|
28
|
-
command: 'rolldown src/main.ts -d dist -n bundle -f iife -e jQuery,window._ -g jQuery=$',
|
|
29
|
-
},
|
|
30
|
-
];
|
|
31
|
-
const notes = [
|
|
32
|
-
'Due to the API limitation, you need to pass `-s` for `.map` sourcemap file as the last argument.',
|
|
33
|
-
'If you are using the configuration, please pass the `-c` as the last argument if you ignore the default configuration file.',
|
|
34
|
-
'CLI options will override the configuration file.',
|
|
35
|
-
'For more information, please visit https://rolldown.rs/.',
|
|
36
|
-
];
|
|
37
|
-
export function showHelp() {
|
|
38
|
-
logger.log(introduction);
|
|
39
|
-
logger.log('');
|
|
40
|
-
logger.log(`${colors.bold(colors.underline('OPTIONS'))}`);
|
|
41
|
-
logger.log('');
|
|
42
|
-
logger.log(Object.entries(options)
|
|
43
|
-
.sort(([a], [b]) => {
|
|
44
|
-
// 1. If one of them has a short option, prioritize it.
|
|
45
|
-
if (options[a].short && !options[b].short) {
|
|
46
|
-
return -1;
|
|
47
|
-
}
|
|
48
|
-
if (!options[a].short && options[b].short) {
|
|
49
|
-
return 1;
|
|
50
|
-
}
|
|
51
|
-
// 2. If both of them have a short option, sort by the short letter.
|
|
52
|
-
if (options[a].short && options[b].short) {
|
|
53
|
-
return options[a].short.localeCompare(options[b].short);
|
|
54
|
-
}
|
|
55
|
-
// 3. If none of them has a short option, sort by the long option.
|
|
56
|
-
return a.localeCompare(b);
|
|
57
|
-
})
|
|
58
|
-
.map(([option, { type, short, hint, description }]) => {
|
|
59
|
-
let optionStr = ` --${option} `;
|
|
60
|
-
option = camelCaseToKebabCase(option);
|
|
61
|
-
if (short) {
|
|
62
|
-
optionStr += `-${short}, `;
|
|
63
|
-
}
|
|
64
|
-
if (type === 'string') {
|
|
65
|
-
optionStr += `<${hint ?? option}>`;
|
|
66
|
-
}
|
|
67
|
-
if (description && description.length > 0) {
|
|
68
|
-
description = description[0].toUpperCase() + description.slice(1);
|
|
69
|
-
}
|
|
70
|
-
return (colors.cyan(optionStr.padEnd(30)) +
|
|
71
|
-
description +
|
|
72
|
-
(description && description?.endsWith('.') ? '' : '.'));
|
|
73
|
-
})
|
|
74
|
-
.join('\n'));
|
|
75
|
-
logger.log('');
|
|
76
|
-
logger.log(`${colors.bold(colors.underline('EXAMPLES'))}`);
|
|
77
|
-
logger.log('');
|
|
78
|
-
examples.forEach(({ title, command }, ord) => {
|
|
79
|
-
logger.log(` ${ord + 1}. ${title}:`);
|
|
80
|
-
logger.log(` ${colors.cyan(command)}`);
|
|
81
|
-
logger.log('');
|
|
82
|
-
});
|
|
83
|
-
logger.log(`${colors.bold(colors.underline('NOTES'))}`);
|
|
84
|
-
logger.log('');
|
|
85
|
-
notes.forEach((note) => {
|
|
86
|
-
logger.log(` * ${colors.gray(note)}`);
|
|
87
|
-
});
|
|
88
|
-
}
|
package/dist/types/cli/index.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import process from 'node:process';
|
|
2
|
-
import { bundleWithCliOptions, bundleWithConfig } from './commands/bundle';
|
|
3
|
-
import { logger } from './logger';
|
|
4
|
-
import { parseCliArguments } from './arguments';
|
|
5
|
-
import { showHelp } from './commands/help';
|
|
6
|
-
import { version } from '../../package.json';
|
|
7
|
-
async function main() {
|
|
8
|
-
const cliOptions = parseCliArguments();
|
|
9
|
-
if (cliOptions.config || cliOptions.config === '') {
|
|
10
|
-
await bundleWithConfig(cliOptions.config, cliOptions);
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
if ('input' in cliOptions.input) {
|
|
14
|
-
// If input is specified, we will bundle with the input options
|
|
15
|
-
await bundleWithCliOptions(cliOptions);
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (cliOptions.version) {
|
|
19
|
-
logger.log(`rolldown v${version}`);
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
showHelp();
|
|
23
|
-
}
|
|
24
|
-
main().catch((err) => {
|
|
25
|
-
logger.error(err);
|
|
26
|
-
process.exit(1);
|
|
27
|
-
});
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { cwd } from 'node:process';
|
|
4
|
-
import { readdir } from 'node:fs/promises';
|
|
5
|
-
import { pathToFileURL } from 'node:url';
|
|
6
|
-
import { rolldown } from '../api/rolldown';
|
|
7
|
-
async function bundleTsConfig(configFile) {
|
|
8
|
-
const dirnameVarName = 'injected_original_dirname';
|
|
9
|
-
const filenameVarName = 'injected_original_filename';
|
|
10
|
-
const importMetaUrlVarName = 'injected_original_import_meta_url';
|
|
11
|
-
const bundle = await rolldown({
|
|
12
|
-
input: configFile,
|
|
13
|
-
platform: 'node',
|
|
14
|
-
resolve: {
|
|
15
|
-
mainFields: ['main'],
|
|
16
|
-
},
|
|
17
|
-
define: {
|
|
18
|
-
__dirname: dirnameVarName,
|
|
19
|
-
__filename: filenameVarName,
|
|
20
|
-
'import.meta.url': importMetaUrlVarName,
|
|
21
|
-
'import.meta.dirname': dirnameVarName,
|
|
22
|
-
'import.meta.filename': filenameVarName,
|
|
23
|
-
},
|
|
24
|
-
treeshake: false,
|
|
25
|
-
external: [/^[\w@][^:]/], // external bare imports
|
|
26
|
-
plugins: [
|
|
27
|
-
{
|
|
28
|
-
name: 'inject-file-scope-variables',
|
|
29
|
-
transform: {
|
|
30
|
-
filter: { id: /\.[cm]?[jt]s$/ },
|
|
31
|
-
async handler(code, id) {
|
|
32
|
-
const injectValues = `const ${dirnameVarName} = ${JSON.stringify(path.dirname(id))};` +
|
|
33
|
-
`const ${filenameVarName} = ${JSON.stringify(id)};` +
|
|
34
|
-
`const ${importMetaUrlVarName} = ${JSON.stringify(pathToFileURL(id).href)};`;
|
|
35
|
-
return { code: injectValues + code, map: null };
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
});
|
|
41
|
-
const outputDir = path.dirname(configFile);
|
|
42
|
-
const result = await bundle.write({
|
|
43
|
-
dir: outputDir,
|
|
44
|
-
format: 'esm',
|
|
45
|
-
sourcemap: 'inline',
|
|
46
|
-
entryFileNames: 'rolldown.config.[hash].js',
|
|
47
|
-
});
|
|
48
|
-
const fileName = result.output.find((chunk) => chunk.type === 'chunk' && chunk.isEntry).fileName;
|
|
49
|
-
return path.join(outputDir, fileName);
|
|
50
|
-
}
|
|
51
|
-
const SUPPORTED_JS_CONFIG_FORMATS = ['.js', '.mjs', '.cjs'];
|
|
52
|
-
const SUPPORTED_TS_CONFIG_FORMATS = ['.ts', '.mts', '.cts'];
|
|
53
|
-
const SUPPORTED_CONFIG_FORMATS = [
|
|
54
|
-
...SUPPORTED_JS_CONFIG_FORMATS,
|
|
55
|
-
...SUPPORTED_TS_CONFIG_FORMATS,
|
|
56
|
-
];
|
|
57
|
-
const DEFAULT_CONFIG_BASE = 'rolldown.config';
|
|
58
|
-
async function findConfigFileNameInCwd() {
|
|
59
|
-
const filesInWorkingDirectory = new Set(await readdir(cwd()));
|
|
60
|
-
for (const extension of SUPPORTED_CONFIG_FORMATS) {
|
|
61
|
-
const fileName = `${DEFAULT_CONFIG_BASE}${extension}`;
|
|
62
|
-
if (filesInWorkingDirectory.has(fileName))
|
|
63
|
-
return fileName;
|
|
64
|
-
}
|
|
65
|
-
throw new Error('No `rolldown.config` configuration file found.');
|
|
66
|
-
}
|
|
67
|
-
export async function loadTsConfig(configFile) {
|
|
68
|
-
const file = await bundleTsConfig(configFile);
|
|
69
|
-
try {
|
|
70
|
-
return (await import(pathToFileURL(file).href)).default;
|
|
71
|
-
}
|
|
72
|
-
finally {
|
|
73
|
-
fs.unlink(file, () => { }); // Ignore errors
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
export async function loadConfig(configPath) {
|
|
77
|
-
const ext = path.extname((configPath = configPath || (await findConfigFileNameInCwd())));
|
|
78
|
-
try {
|
|
79
|
-
if (SUPPORTED_JS_CONFIG_FORMATS.includes(ext) ||
|
|
80
|
-
(process.env.NODE_OPTIONS?.includes('--import=tsx') &&
|
|
81
|
-
SUPPORTED_TS_CONFIG_FORMATS.includes(ext))) {
|
|
82
|
-
return (await import(pathToFileURL(configPath).href)).default;
|
|
83
|
-
}
|
|
84
|
-
else if (SUPPORTED_TS_CONFIG_FORMATS.includes(ext)) {
|
|
85
|
-
const rawConfigPath = path.resolve(configPath);
|
|
86
|
-
return await loadTsConfig(rawConfigPath);
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
throw new Error(`Unsupported config format. Expected: \`${SUPPORTED_CONFIG_FORMATS.join(',')}\` but got \`${ext}\``);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
catch (err) {
|
|
93
|
-
throw new Error('Error happened while loading config.', { cause: err });
|
|
94
|
-
}
|
|
95
|
-
}
|
package/dist/types/cli/logger.js
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { createConsola } from 'consola';
|
|
2
|
-
/**
|
|
3
|
-
* Console logger
|
|
4
|
-
*/
|
|
5
|
-
export const logger = process.env
|
|
6
|
-
.ROLLDOWN_TEST
|
|
7
|
-
? createTestingLogger()
|
|
8
|
-
: createConsola({
|
|
9
|
-
formatOptions: {
|
|
10
|
-
date: false,
|
|
11
|
-
},
|
|
12
|
-
});
|
|
13
|
-
function createTestingLogger() {
|
|
14
|
-
const types = [
|
|
15
|
-
'silent',
|
|
16
|
-
'fatal',
|
|
17
|
-
'error',
|
|
18
|
-
'warn',
|
|
19
|
-
'log',
|
|
20
|
-
'info',
|
|
21
|
-
'success',
|
|
22
|
-
'fail',
|
|
23
|
-
'ready',
|
|
24
|
-
'start',
|
|
25
|
-
'box',
|
|
26
|
-
'debug',
|
|
27
|
-
'trace',
|
|
28
|
-
'verbose',
|
|
29
|
-
];
|
|
30
|
-
const ret = Object.create(null);
|
|
31
|
-
for (const type of types) {
|
|
32
|
-
ret[type] = console.log;
|
|
33
|
-
}
|
|
34
|
-
return ret;
|
|
35
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* If Composed plugins call `this.resolve` with `skipSelf: true`, the composed plugins will be skipped as a whole.
|
|
3
|
-
* To prevent that, we use this symbol to store the actual caller of `this.resolve` with `skipSelf: true`. And we
|
|
4
|
-
* will modify the skipSelf option to `false` and use this symbol to skip the caller itself in the composed plugins
|
|
5
|
-
* internally.
|
|
6
|
-
*/
|
|
7
|
-
export const SYMBOL_FOR_RESOLVE_CALLER_THAT_SKIP_SELF = Symbol('plugin-context-resolve-caller');
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
export const ENUMERATED_INPUT_PLUGIN_HOOK_NAMES = [
|
|
2
|
-
'options',
|
|
3
|
-
'buildStart',
|
|
4
|
-
'resolveId',
|
|
5
|
-
'load',
|
|
6
|
-
'transform',
|
|
7
|
-
'moduleParsed',
|
|
8
|
-
'buildEnd',
|
|
9
|
-
'onLog',
|
|
10
|
-
'resolveDynamicImport',
|
|
11
|
-
'closeBundle',
|
|
12
|
-
'closeWatcher',
|
|
13
|
-
'watchChange',
|
|
14
|
-
];
|
|
15
|
-
export const ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES = [
|
|
16
|
-
'augmentChunkHash',
|
|
17
|
-
'outputOptions',
|
|
18
|
-
'renderChunk',
|
|
19
|
-
'renderStart',
|
|
20
|
-
'renderError',
|
|
21
|
-
'writeBundle',
|
|
22
|
-
'generateBundle',
|
|
23
|
-
];
|
|
24
|
-
export const ENUMERATED_PLUGIN_HOOK_NAMES = [
|
|
25
|
-
// build hooks
|
|
26
|
-
...ENUMERATED_INPUT_PLUGIN_HOOK_NAMES,
|
|
27
|
-
// generate hooks
|
|
28
|
-
...ENUMERATED_OUTPUT_PLUGIN_HOOK_NAMES,
|
|
29
|
-
// addon hooks
|
|
30
|
-
'footer',
|
|
31
|
-
'banner',
|
|
32
|
-
'intro',
|
|
33
|
-
'outro',
|
|
34
|
-
];
|
|
35
|
-
/**
|
|
36
|
-
* Names of all defined hooks. It's like
|
|
37
|
-
* ```js
|
|
38
|
-
* const DEFINED_HOOK_NAMES ={
|
|
39
|
-
* options: 'options',
|
|
40
|
-
* buildStart: 'buildStart',
|
|
41
|
-
* ...
|
|
42
|
-
* }
|
|
43
|
-
* ```
|
|
44
|
-
*/
|
|
45
|
-
export const DEFINED_HOOK_NAMES = {
|
|
46
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[0]]: ENUMERATED_PLUGIN_HOOK_NAMES[0],
|
|
47
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[1]]: ENUMERATED_PLUGIN_HOOK_NAMES[1],
|
|
48
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[2]]: ENUMERATED_PLUGIN_HOOK_NAMES[2],
|
|
49
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[3]]: ENUMERATED_PLUGIN_HOOK_NAMES[3],
|
|
50
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[4]]: ENUMERATED_PLUGIN_HOOK_NAMES[4],
|
|
51
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[5]]: ENUMERATED_PLUGIN_HOOK_NAMES[5],
|
|
52
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[6]]: ENUMERATED_PLUGIN_HOOK_NAMES[6],
|
|
53
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[7]]: ENUMERATED_PLUGIN_HOOK_NAMES[7],
|
|
54
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[8]]: ENUMERATED_PLUGIN_HOOK_NAMES[8],
|
|
55
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[9]]: ENUMERATED_PLUGIN_HOOK_NAMES[9],
|
|
56
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[10]]: ENUMERATED_PLUGIN_HOOK_NAMES[10],
|
|
57
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[11]]: ENUMERATED_PLUGIN_HOOK_NAMES[11],
|
|
58
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[12]]: ENUMERATED_PLUGIN_HOOK_NAMES[12],
|
|
59
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[13]]: ENUMERATED_PLUGIN_HOOK_NAMES[13],
|
|
60
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[14]]: ENUMERATED_PLUGIN_HOOK_NAMES[14],
|
|
61
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[15]]: ENUMERATED_PLUGIN_HOOK_NAMES[15],
|
|
62
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[16]]: ENUMERATED_PLUGIN_HOOK_NAMES[16],
|
|
63
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[17]]: ENUMERATED_PLUGIN_HOOK_NAMES[17],
|
|
64
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[18]]: ENUMERATED_PLUGIN_HOOK_NAMES[18],
|
|
65
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[19]]: ENUMERATED_PLUGIN_HOOK_NAMES[19],
|
|
66
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[20]]: ENUMERATED_PLUGIN_HOOK_NAMES[20],
|
|
67
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[21]]: ENUMERATED_PLUGIN_HOOK_NAMES[21],
|
|
68
|
-
[ENUMERATED_PLUGIN_HOOK_NAMES[22]]: ENUMERATED_PLUGIN_HOOK_NAMES[22],
|
|
69
|
-
};
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
export { defineParallelPlugin } from './plugin/parallel-plugin';
|
|
2
|
-
export { experimental_scan as scan } from './api/experimental';
|
|
3
|
-
export { transform } from './binding';
|
|
4
|
-
export { composeJsPlugins as composePlugins } from './utils/compose-js-plugins';
|
|
5
|
-
// Builtin plugin factory
|
|
6
|
-
export { modulePreloadPolyfillPlugin, dynamicImportVarsPlugin, wasmHelperPlugin, wasmFallbackPlugin, importGlobPlugin, manifestPlugin, loadFallbackPlugin, jsonPlugin, buildImportAnalysisPlugin, viteResolvePlugin, moduleFederationPlugin, } from './builtin-plugin/constructors';
|
|
7
|
-
export { transformPlugin } from './builtin-plugin/transform-plugin';
|
|
8
|
-
export { replacePlugin } from './builtin-plugin/replace-plugin';
|
|
9
|
-
export { aliasPlugin } from './builtin-plugin/alias-plugin';
|
package/dist/types/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from './utils/define-config';
|
|
2
|
-
import { rolldown } from './api/rolldown';
|
|
3
|
-
import { watch } from './api/watch';
|
|
4
|
-
import { version } from '../package.json';
|
|
5
|
-
import { build } from './api/build';
|
|
6
|
-
export { defineConfig, rolldown, watch, build };
|
|
7
|
-
export const VERSION = version;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { noop } from '../utils/misc';
|
|
2
|
-
import { LOG_LEVEL_WARN, logLevelPriority, } from './logging';
|
|
3
|
-
import { logInvalidLogPosition } from './logs';
|
|
4
|
-
export const normalizeLog = (log) => typeof log === 'string'
|
|
5
|
-
? { message: log }
|
|
6
|
-
: typeof log === 'function'
|
|
7
|
-
? normalizeLog(log())
|
|
8
|
-
: log;
|
|
9
|
-
export function getLogHandler(level, code, logger, pluginName, logLevel) {
|
|
10
|
-
if (logLevelPriority[level] < logLevelPriority[logLevel]) {
|
|
11
|
-
return noop;
|
|
12
|
-
}
|
|
13
|
-
return (log, pos) => {
|
|
14
|
-
if (pos != null) {
|
|
15
|
-
logger(LOG_LEVEL_WARN, logInvalidLogPosition(pluginName));
|
|
16
|
-
}
|
|
17
|
-
log = normalizeLog(log);
|
|
18
|
-
if (log.code && !log.pluginCode) {
|
|
19
|
-
log.pluginCode = log.code;
|
|
20
|
-
}
|
|
21
|
-
log.code = code;
|
|
22
|
-
log.plugin = pluginName;
|
|
23
|
-
logger(level, log);
|
|
24
|
-
};
|
|
25
|
-
}
|
package/dist/types/log/logger.js
DELETED
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
import { LOG_LEVEL_DEBUG, LOG_LEVEL_INFO, LOG_LEVEL_WARN, LOG_LEVEL_ERROR, logLevelPriority, } from './logging';
|
|
2
|
-
import { error } from './logs';
|
|
3
|
-
import { normalizeLog } from './logHandler';
|
|
4
|
-
import path from 'node:path';
|
|
5
|
-
import { VERSION } from '..';
|
|
6
|
-
import { getSortedPlugins } from '../plugin/plugin-driver';
|
|
7
|
-
export function getLogger(plugins, onLog, logLevel) {
|
|
8
|
-
const minimalPriority = logLevelPriority[logLevel];
|
|
9
|
-
const logger = (level, log, skipped = new Set()) => {
|
|
10
|
-
const logPriority = logLevelPriority[level];
|
|
11
|
-
if (logPriority < minimalPriority) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
for (const plugin of getSortedPlugins('onLog', plugins)) {
|
|
15
|
-
if (skipped.has(plugin))
|
|
16
|
-
continue;
|
|
17
|
-
const { onLog: pluginOnLog } = plugin;
|
|
18
|
-
if (pluginOnLog) {
|
|
19
|
-
const getLogHandler = (level) => {
|
|
20
|
-
if (logLevelPriority[level] < minimalPriority) {
|
|
21
|
-
return () => { };
|
|
22
|
-
}
|
|
23
|
-
return (log) => logger(level, normalizeLog(log), new Set(skipped).add(plugin));
|
|
24
|
-
};
|
|
25
|
-
const handler = 'handler' in pluginOnLog ? pluginOnLog.handler : pluginOnLog;
|
|
26
|
-
if (handler.call({
|
|
27
|
-
debug: getLogHandler(LOG_LEVEL_DEBUG),
|
|
28
|
-
error: (log) => error(normalizeLog(log)),
|
|
29
|
-
info: getLogHandler(LOG_LEVEL_INFO),
|
|
30
|
-
meta: {
|
|
31
|
-
rollupVersion: '4.23.0',
|
|
32
|
-
rolldownVersion: VERSION,
|
|
33
|
-
watchMode: false,
|
|
34
|
-
},
|
|
35
|
-
warn: getLogHandler(LOG_LEVEL_WARN),
|
|
36
|
-
pluginName: plugin.name || 'unknown',
|
|
37
|
-
}, level, log) === false) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
onLog(level, log);
|
|
43
|
-
};
|
|
44
|
-
return logger;
|
|
45
|
-
}
|
|
46
|
-
export const getOnLog = (config, logLevel, printLog = defaultPrintLog) => {
|
|
47
|
-
const { onwarn, onLog } = config;
|
|
48
|
-
const defaultOnLog = getDefaultOnLog(printLog, onwarn);
|
|
49
|
-
if (onLog) {
|
|
50
|
-
const minimalPriority = logLevelPriority[logLevel];
|
|
51
|
-
return (level, log) => onLog(level, addLogToString(log), (level, handledLog) => {
|
|
52
|
-
if (level === LOG_LEVEL_ERROR) {
|
|
53
|
-
return error(normalizeLog(handledLog));
|
|
54
|
-
}
|
|
55
|
-
if (logLevelPriority[level] >= minimalPriority) {
|
|
56
|
-
defaultOnLog(level, normalizeLog(handledLog));
|
|
57
|
-
}
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
return defaultOnLog;
|
|
61
|
-
};
|
|
62
|
-
const getDefaultOnLog = (printLog, onwarn) => onwarn
|
|
63
|
-
? (level, log) => {
|
|
64
|
-
if (level === LOG_LEVEL_WARN) {
|
|
65
|
-
onwarn(addLogToString(log), (warning) => printLog(LOG_LEVEL_WARN, normalizeLog(warning)));
|
|
66
|
-
}
|
|
67
|
-
else {
|
|
68
|
-
printLog(level, log);
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
: printLog;
|
|
72
|
-
const addLogToString = (log) => {
|
|
73
|
-
Object.defineProperty(log, 'toString', {
|
|
74
|
-
value: () => getExtendedLogMessage(log),
|
|
75
|
-
writable: true,
|
|
76
|
-
});
|
|
77
|
-
return log;
|
|
78
|
-
};
|
|
79
|
-
const defaultPrintLog = (level, log) => {
|
|
80
|
-
const message = getExtendedLogMessage(log);
|
|
81
|
-
switch (level) {
|
|
82
|
-
case LOG_LEVEL_WARN: {
|
|
83
|
-
return console.warn(message);
|
|
84
|
-
}
|
|
85
|
-
case LOG_LEVEL_DEBUG: {
|
|
86
|
-
return console.debug(message);
|
|
87
|
-
}
|
|
88
|
-
default: {
|
|
89
|
-
return console.info(message);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
const getExtendedLogMessage = (log) => {
|
|
94
|
-
let prefix = '';
|
|
95
|
-
if (log.plugin) {
|
|
96
|
-
prefix += `(${log.plugin} plugin) `;
|
|
97
|
-
}
|
|
98
|
-
if (log.loc) {
|
|
99
|
-
prefix += `${relativeId(log.loc.file)} (${log.loc.line}:${log.loc.column}) `;
|
|
100
|
-
}
|
|
101
|
-
return prefix + log.message;
|
|
102
|
-
};
|
|
103
|
-
function relativeId(id) {
|
|
104
|
-
if (!path.isAbsolute(id))
|
|
105
|
-
return id;
|
|
106
|
-
return path.relative(path.resolve(), id);
|
|
107
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export const LOG_LEVEL_SILENT = 'silent';
|
|
2
|
-
export const LOG_LEVEL_ERROR = 'error';
|
|
3
|
-
export const LOG_LEVEL_WARN = 'warn';
|
|
4
|
-
export const LOG_LEVEL_INFO = 'info';
|
|
5
|
-
export const LOG_LEVEL_DEBUG = 'debug';
|
|
6
|
-
export const logLevelPriority = {
|
|
7
|
-
[LOG_LEVEL_DEBUG]: 0,
|
|
8
|
-
[LOG_LEVEL_INFO]: 1,
|
|
9
|
-
[LOG_LEVEL_WARN]: 2,
|
|
10
|
-
[LOG_LEVEL_SILENT]: 3,
|
|
11
|
-
};
|
package/dist/types/log/logs.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { getCodeFrame } from '../utils/code-frame';
|
|
2
|
-
import { locate } from './locate-character';
|
|
3
|
-
import { colors } from '../cli/colors';
|
|
4
|
-
const INVALID_LOG_POSITION = 'INVALID_LOG_POSITION', PLUGIN_ERROR = 'PLUGIN_ERROR', INPUT_HOOK_IN_OUTPUT_PLUGIN = 'INPUT_HOOK_IN_OUTPUT_PLUGIN', CYCLE_LOADING = 'CYCLE_LOADING', MULTIPLY_NOTIFY_OPTION = 'MULTIPLY_NOTIFY_OPTION', MINIFY_WARNING = 'MINIFY_WARNING', PARSE_ERROR = 'PARSE_ERROR';
|
|
5
|
-
export function logParseError(message) {
|
|
6
|
-
return {
|
|
7
|
-
code: PARSE_ERROR,
|
|
8
|
-
message,
|
|
9
|
-
};
|
|
10
|
-
}
|
|
11
|
-
export function logMinifyWarning() {
|
|
12
|
-
return {
|
|
13
|
-
code: MINIFY_WARNING,
|
|
14
|
-
message: colors.yellow('The built-in minifier is still under development. Setting "minify: true" is not recommended for production use.'),
|
|
15
|
-
};
|
|
16
|
-
}
|
|
17
|
-
export function logInvalidLogPosition(pluginName) {
|
|
18
|
-
return {
|
|
19
|
-
code: INVALID_LOG_POSITION,
|
|
20
|
-
message: `Plugin "${pluginName}" tried to add a file position to a log or warning. This is only supported in the "transform" hook at the moment and will be ignored.`,
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export function logInputHookInOutputPlugin(pluginName, hookName) {
|
|
24
|
-
return {
|
|
25
|
-
code: INPUT_HOOK_IN_OUTPUT_PLUGIN,
|
|
26
|
-
message: `The "${hookName}" hook used by the output plugin ${pluginName} is a build time hook and will not be run for that plugin. Either this plugin cannot be used as an output plugin, or it should have an option to configure it as an output plugin.`,
|
|
27
|
-
};
|
|
28
|
-
}
|
|
29
|
-
export function logCycleLoading(pluginName, moduleId) {
|
|
30
|
-
return {
|
|
31
|
-
code: CYCLE_LOADING,
|
|
32
|
-
message: `Found the module "${moduleId}" cycle loading at ${pluginName} plugin, it maybe blocking fetching modules.`,
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
export function logMultiplyNotifyOption() {
|
|
36
|
-
return {
|
|
37
|
-
code: MULTIPLY_NOTIFY_OPTION,
|
|
38
|
-
message: `Found multiply notify option at watch options, using first one to start notify watcher.`,
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
export function logPluginError(error, plugin, { hook, id } = {}) {
|
|
42
|
-
const code = error.code;
|
|
43
|
-
if (!error.pluginCode &&
|
|
44
|
-
code != null &&
|
|
45
|
-
(typeof code !== 'string' || !code.startsWith('PLUGIN_'))) {
|
|
46
|
-
error.pluginCode = code;
|
|
47
|
-
}
|
|
48
|
-
error.code = PLUGIN_ERROR;
|
|
49
|
-
error.plugin = plugin;
|
|
50
|
-
if (hook) {
|
|
51
|
-
error.hook = hook;
|
|
52
|
-
}
|
|
53
|
-
if (id) {
|
|
54
|
-
error.id = id;
|
|
55
|
-
}
|
|
56
|
-
return error;
|
|
57
|
-
}
|
|
58
|
-
export function error(base) {
|
|
59
|
-
if (!(base instanceof Error)) {
|
|
60
|
-
base = Object.assign(new Error(base.message), base);
|
|
61
|
-
Object.defineProperty(base, 'name', {
|
|
62
|
-
value: 'RollupError',
|
|
63
|
-
writable: true,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
throw base;
|
|
67
|
-
}
|
|
68
|
-
export function augmentCodeLocation(properties, pos, source, id) {
|
|
69
|
-
if (typeof pos === 'object') {
|
|
70
|
-
const { line, column } = pos;
|
|
71
|
-
properties.loc = { column, file: id, line };
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
properties.pos = pos;
|
|
75
|
-
const location = locate(source, pos, { offsetLine: 1 });
|
|
76
|
-
if (!location) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const { line, column } = location;
|
|
80
|
-
properties.loc = { column, file: id, line };
|
|
81
|
-
}
|
|
82
|
-
if (properties.frame === undefined) {
|
|
83
|
-
const { line, column } = properties.loc;
|
|
84
|
-
properties.frame = getCodeFrame(source, line, column);
|
|
85
|
-
}
|
|
86
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// TODO: I guess we make these getters enumerable so it act more like a plain object
|
|
2
|
-
export class NormalizedInputOptionsImpl {
|
|
3
|
-
onLog;
|
|
4
|
-
inner;
|
|
5
|
-
constructor(inner, onLog) {
|
|
6
|
-
this.onLog = onLog;
|
|
7
|
-
this.inner = inner;
|
|
8
|
-
}
|
|
9
|
-
get shimMissingExports() {
|
|
10
|
-
return this.inner.shimMissingExports;
|
|
11
|
-
}
|
|
12
|
-
get input() {
|
|
13
|
-
return this.inner.input;
|
|
14
|
-
}
|
|
15
|
-
get cwd() {
|
|
16
|
-
return this.inner.cwd ?? undefined;
|
|
17
|
-
}
|
|
18
|
-
get platform() {
|
|
19
|
-
return this.inner.platform;
|
|
20
|
-
}
|
|
21
|
-
}
|