@samual/rolldown-config 0.0.1-5e79465 → 0.0.1-62d6139
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/default.d.ts +76 -75
- package/default.js +20 -16
- package/package.json +12 -11
package/default.d.ts
CHANGED
|
@@ -1,84 +1,85 @@
|
|
|
1
1
|
import { type RollupBabelInputPluginOptions } from "@rollup/plugin-babel";
|
|
2
2
|
import { type Options as TerserOptions } from "@rollup/plugin-terser";
|
|
3
|
-
import type { LaxPartial } from "@samual/
|
|
3
|
+
import type { LaxPartial } from "@samual/types";
|
|
4
4
|
import type { RolldownOptions } from "rolldown";
|
|
5
5
|
import { type Options as PrettierOptions } from "rollup-plugin-prettier";
|
|
6
6
|
type Options = LaxPartial<{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
7
|
+
/**
|
|
8
|
+
* Override the source folder.
|
|
9
|
+
* @default "src"
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```js
|
|
13
|
+
* // rolldown.config.js
|
|
14
|
+
* import { rolldownConfig } from "@samual/rolldown-config"
|
|
15
|
+
*
|
|
16
|
+
* export default rolldownConfig({ sourcePath: "source" })
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
sourcePath: string;
|
|
20
|
+
/**
|
|
21
|
+
* Override any Rolldown options.
|
|
22
|
+
* @see [Official Rolldown docs.](https://rolldown.rs/reference/config-options)
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```ts
|
|
26
|
+
* // rolldown.config.js
|
|
27
|
+
* import { rolldownConfig } from "@samual/rolldown-config"
|
|
28
|
+
*
|
|
29
|
+
* // You can override the output folder like so:
|
|
30
|
+
* export default rolldownConfig({ rolldownOptions: { output: { dir: "build" } } })
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
rolldownOptions: RolldownOptions;
|
|
34
|
+
/**
|
|
35
|
+
* Override any Babel options.
|
|
36
|
+
* @see [Official Babel docs.](https://babeljs.io/docs/options)
|
|
37
|
+
*/
|
|
38
|
+
babelOptions: RollupBabelInputPluginOptions;
|
|
39
|
+
/**
|
|
40
|
+
* Override any Terser options.
|
|
41
|
+
* @see [Official Terser docs.](https://terser.org/docs/options/)
|
|
42
|
+
*/
|
|
43
|
+
terserOptions: TerserOptions;
|
|
44
|
+
/**
|
|
45
|
+
* Override any Prettier options.
|
|
46
|
+
* @see [Official Prettier docs.](https://prettier.io/docs/en/options)
|
|
47
|
+
*/
|
|
48
|
+
prettierOptions: PrettierOptions;
|
|
49
|
+
experimental: LaxPartial<{
|
|
50
|
+
noSideEffects: boolean;
|
|
51
|
+
disablePrettier: boolean;
|
|
52
|
+
}>;
|
|
52
53
|
}>;
|
|
53
54
|
/**
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
55
|
+
* Construct a {@linkcode RollupOptions} object.
|
|
56
|
+
*
|
|
57
|
+
* Compiles all `.js` and `.ts` files (excludes `.test.js`, `.test.ts`, and `.d.ts`) found in the
|
|
58
|
+
* {@linkcode Options.sourcePath sourcePath}.
|
|
59
|
+
*
|
|
60
|
+
* @see {@linkcode Options}
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```text
|
|
64
|
+
* src/
|
|
65
|
+
* env.d.ts
|
|
66
|
+
* foo.ts
|
|
67
|
+
* bar/
|
|
68
|
+
* baz.ts
|
|
69
|
+
* baz.test.ts
|
|
70
|
+
* dist/
|
|
71
|
+
* foo.js
|
|
72
|
+
* bar/
|
|
73
|
+
* baz.js
|
|
74
|
+
* ```
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* ```js
|
|
78
|
+
* // rolldown.config.js
|
|
79
|
+
* import { rolldownConfig } from "@samual/rolldown-config"
|
|
80
|
+
*
|
|
81
|
+
* export default rolldownConfig()
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
83
84
|
export declare const rolldownConfig: ({ sourcePath, rolldownOptions, babelOptions, terserOptions, prettierOptions, experimental }?: Options) => Promise<RolldownOptions>;
|
|
84
85
|
export {};
|
package/default.js
CHANGED
|
@@ -4,11 +4,11 @@ import babelPresetEnv from "@babel/preset-env"
|
|
|
4
4
|
import babelPresetTypescript from "@babel/preset-typescript"
|
|
5
5
|
import { babel } from "@rollup/plugin-babel"
|
|
6
6
|
import terser from "@rollup/plugin-terser"
|
|
7
|
-
import {
|
|
8
|
-
import { findFiles } from "@samual/lib/findFiles"
|
|
7
|
+
import { expect } from "@samual/assert"
|
|
9
8
|
import { babelPluginHere } from "babel-plugin-here"
|
|
10
9
|
import { babelPluginVitest } from "babel-plugin-vitest"
|
|
11
10
|
import { defu } from "defu"
|
|
11
|
+
import { readdir } from "fs/promises"
|
|
12
12
|
import { cpus } from "os"
|
|
13
13
|
import * as Path from "path"
|
|
14
14
|
import prettier from "rollup-plugin-prettier"
|
|
@@ -23,7 +23,9 @@ const rolldownConfig = async ({
|
|
|
23
23
|
defu(rolldownOptions, {
|
|
24
24
|
external: source => !(Path.isAbsolute(source) || source.startsWith(".")),
|
|
25
25
|
input: Object.fromEntries(
|
|
26
|
-
(await
|
|
26
|
+
(await readdir(sourcePath, { withFileTypes: !0, recursive: !0 }))
|
|
27
|
+
.filter(dirent => dirent.isFile())
|
|
28
|
+
.map(dirent => Path.join((dirent => dirent.parentPath ?? dirent.path)(dirent), dirent.name))
|
|
27
29
|
.filter(
|
|
28
30
|
path =>
|
|
29
31
|
(path.endsWith(".js") && !path.endsWith(".test.js")) ||
|
|
@@ -46,7 +48,7 @@ const rolldownConfig = async ({
|
|
|
46
48
|
),
|
|
47
49
|
terser(
|
|
48
50
|
defu(terserOptions, {
|
|
49
|
-
compress: { passes: 1 / 0, unsafe: !0, sequences: !1 },
|
|
51
|
+
compress: { passes: 1 / 0, unsafe: !0, sequences: !1, keep_infinity: !0 },
|
|
50
52
|
maxWorkers: Math.floor(cpus().length / 2),
|
|
51
53
|
mangle: !1,
|
|
52
54
|
ecma: 2020
|
|
@@ -55,7 +57,7 @@ const rolldownConfig = async ({
|
|
|
55
57
|
experimental?.noSideEffects && {
|
|
56
58
|
name: "no-side-effects",
|
|
57
59
|
async renderChunk(code) {
|
|
58
|
-
const ast =
|
|
60
|
+
const ast = expect(await parseAsync(code, { plugins: [babelPluginSyntaxTypescript] })),
|
|
59
61
|
indexes = []
|
|
60
62
|
traverse(ast, {
|
|
61
63
|
Function(path) {
|
|
@@ -72,17 +74,19 @@ const rolldownConfig = async ({
|
|
|
72
74
|
return code
|
|
73
75
|
}
|
|
74
76
|
},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
77
|
+
experimental?.disablePrettier
|
|
78
|
+
? void 0
|
|
79
|
+
: prettier(
|
|
80
|
+
defu(prettierOptions, {
|
|
81
|
+
parser: "espree",
|
|
82
|
+
useTabs: !0,
|
|
83
|
+
tabWidth: 4,
|
|
84
|
+
arrowParens: "avoid",
|
|
85
|
+
printWidth: 120,
|
|
86
|
+
semi: !1,
|
|
87
|
+
trailingComma: "none"
|
|
88
|
+
})
|
|
89
|
+
)
|
|
86
90
|
],
|
|
87
91
|
preserveEntrySignatures: "strict",
|
|
88
92
|
treeshake: { moduleSideEffects: !1 }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@samual/rolldown-config",
|
|
3
|
-
"version": "0.0.1-
|
|
3
|
+
"version": "0.0.1-62d6139",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "My Rolldown config",
|
|
6
6
|
"keywords": [
|
|
@@ -19,18 +19,19 @@
|
|
|
19
19
|
},
|
|
20
20
|
"repository": "github:samualtnorman/rolldown-config",
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@babel/core": "^7.
|
|
23
|
-
"@babel/plugin-syntax-typescript": "^7
|
|
24
|
-
"@babel/preset-env": "^7
|
|
25
|
-
"@babel/preset-typescript": "^7
|
|
26
|
-
"@rollup/plugin-babel": "^6
|
|
22
|
+
"@babel/core": "^7.19",
|
|
23
|
+
"@babel/plugin-syntax-typescript": "^7",
|
|
24
|
+
"@babel/preset-env": "^7",
|
|
25
|
+
"@babel/preset-typescript": "^7",
|
|
26
|
+
"@rollup/plugin-babel": "^6",
|
|
27
27
|
"@rollup/plugin-terser": "^0.4.4",
|
|
28
|
-
"@samual/
|
|
29
|
-
"
|
|
28
|
+
"@samual/assert": "0.0.1-fc7f76d",
|
|
29
|
+
"@samual/types": "0.0.2-23ffc7f",
|
|
30
|
+
"babel-plugin-here": "1.0.3-0e10245",
|
|
30
31
|
"babel-plugin-vitest": "0.0.1-7dc1dde",
|
|
31
|
-
"defu": "^6
|
|
32
|
-
"rolldown": "1.0.0-
|
|
33
|
-
"rollup-plugin-prettier": "^4
|
|
32
|
+
"defu": "^6",
|
|
33
|
+
"rolldown": "1.0.0-rc.4",
|
|
34
|
+
"rollup-plugin-prettier": "^4"
|
|
34
35
|
},
|
|
35
36
|
"pnpm": {
|
|
36
37
|
"patchedDependencies": {
|