@samual/rolldown-config 0.0.1-ad87f81 → 0.0.1-b62da1f
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 +5 -3
- package/default.js +31 -16
- package/package.json +8 -6
package/default.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { type RollupBabelInputPluginOptions } from "@rollup/plugin-babel";
|
|
2
2
|
import { type Options as TerserOptions } from "@rollup/plugin-terser";
|
|
3
|
+
import { type Options as PrettierOptions } from "@samual/rolldown-plugin-prettier";
|
|
3
4
|
import type { LaxPartial } from "@samual/types";
|
|
4
|
-
import type { RolldownOptions } from "rolldown";
|
|
5
|
-
import { type Options as PrettierOptions } from "rollup-plugin-prettier";
|
|
5
|
+
import type { ConfigExport, RolldownOptions } from "rolldown";
|
|
6
6
|
type Options = LaxPartial<{
|
|
7
7
|
/**
|
|
8
8
|
* Override the source folder.
|
|
@@ -48,6 +48,8 @@ type Options = LaxPartial<{
|
|
|
48
48
|
prettierOptions: PrettierOptions;
|
|
49
49
|
experimental: LaxPartial<{
|
|
50
50
|
noSideEffects: boolean;
|
|
51
|
+
disablePrettier: boolean;
|
|
52
|
+
dts: boolean;
|
|
51
53
|
}>;
|
|
52
54
|
}>;
|
|
53
55
|
/**
|
|
@@ -80,5 +82,5 @@ type Options = LaxPartial<{
|
|
|
80
82
|
* export default rolldownConfig()
|
|
81
83
|
* ```
|
|
82
84
|
*/
|
|
83
|
-
export declare const rolldownConfig: (
|
|
85
|
+
export declare const rolldownConfig: (options?: Options) => ConfigExport | Promise<ConfigExport>;
|
|
84
86
|
export {};
|
package/default.js
CHANGED
|
@@ -5,13 +5,14 @@ import babelPresetTypescript from "@babel/preset-typescript"
|
|
|
5
5
|
import { babel } from "@rollup/plugin-babel"
|
|
6
6
|
import terser from "@rollup/plugin-terser"
|
|
7
7
|
import { expect } from "@samual/assert"
|
|
8
|
+
import prettier from "@samual/rolldown-plugin-prettier"
|
|
8
9
|
import { babelPluginHere } from "babel-plugin-here"
|
|
9
10
|
import { babelPluginVitest } from "babel-plugin-vitest"
|
|
10
11
|
import { defu } from "defu"
|
|
11
12
|
import { readdir } from "fs/promises"
|
|
12
13
|
import { cpus } from "os"
|
|
13
14
|
import * as Path from "path"
|
|
14
|
-
import
|
|
15
|
+
import { dts } from "rolldown-plugin-dts"
|
|
15
16
|
const rolldownConfig = async ({
|
|
16
17
|
sourcePath = "src",
|
|
17
18
|
rolldownOptions,
|
|
@@ -19,13 +20,22 @@ const rolldownConfig = async ({
|
|
|
19
20
|
terserOptions,
|
|
20
21
|
prettierOptions,
|
|
21
22
|
experimental
|
|
22
|
-
} = {}) =>
|
|
23
|
-
defu(
|
|
23
|
+
} = {}) => {
|
|
24
|
+
prettierOptions = defu(prettierOptions, {
|
|
25
|
+
parser: "espree",
|
|
26
|
+
useTabs: !0,
|
|
27
|
+
tabWidth: 4,
|
|
28
|
+
arrowParens: "avoid",
|
|
29
|
+
printWidth: 120,
|
|
30
|
+
semi: !1,
|
|
31
|
+
trailingComma: "none"
|
|
32
|
+
})
|
|
33
|
+
const config = defu(rolldownOptions, {
|
|
24
34
|
external: source => !(Path.isAbsolute(source) || source.startsWith(".")),
|
|
25
35
|
input: Object.fromEntries(
|
|
26
36
|
(await readdir(sourcePath, { withFileTypes: !0, recursive: !0 }))
|
|
27
37
|
.filter(dirent => dirent.isFile())
|
|
28
|
-
.map(dirent => Path.join((dirent => dirent.parentPath ?? dirent.path)(dirent), dirent.name))
|
|
38
|
+
.map(dirent => Path.join((dirent => expect(dirent.parentPath ?? dirent.path))(dirent), dirent.name))
|
|
29
39
|
.filter(
|
|
30
40
|
path =>
|
|
31
41
|
(path.endsWith(".js") && !path.endsWith(".test.js")) ||
|
|
@@ -48,7 +58,7 @@ const rolldownConfig = async ({
|
|
|
48
58
|
),
|
|
49
59
|
terser(
|
|
50
60
|
defu(terserOptions, {
|
|
51
|
-
compress: { passes:
|
|
61
|
+
compress: { passes: Infinity, unsafe: !0, sequences: !1, keep_infinity: !0 },
|
|
52
62
|
maxWorkers: Math.floor(cpus().length / 2),
|
|
53
63
|
mangle: !1,
|
|
54
64
|
ecma: 2020
|
|
@@ -74,19 +84,24 @@ const rolldownConfig = async ({
|
|
|
74
84
|
return code
|
|
75
85
|
}
|
|
76
86
|
},
|
|
77
|
-
prettier(
|
|
78
|
-
defu(prettierOptions, {
|
|
79
|
-
parser: "espree",
|
|
80
|
-
useTabs: !0,
|
|
81
|
-
tabWidth: 4,
|
|
82
|
-
arrowParens: "avoid",
|
|
83
|
-
printWidth: 120,
|
|
84
|
-
semi: !1,
|
|
85
|
-
trailingComma: "none"
|
|
86
|
-
})
|
|
87
|
-
)
|
|
87
|
+
experimental?.disablePrettier ? void 0 : prettier(prettierOptions)
|
|
88
88
|
],
|
|
89
89
|
preserveEntrySignatures: "strict",
|
|
90
90
|
treeshake: { moduleSideEffects: !1 }
|
|
91
91
|
})
|
|
92
|
+
return experimental?.dts
|
|
93
|
+
? [
|
|
94
|
+
config,
|
|
95
|
+
{
|
|
96
|
+
external: config.external,
|
|
97
|
+
input: config.input,
|
|
98
|
+
output: config.output,
|
|
99
|
+
plugins: [
|
|
100
|
+
dts({ oxc: !0, emitDtsOnly: !0 }),
|
|
101
|
+
experimental.disablePrettier ? void 0 : prettier({ ...prettierOptions, parser: "babel-ts" })
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
]
|
|
105
|
+
: config
|
|
106
|
+
}
|
|
92
107
|
export { rolldownConfig }
|
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-b62da1f",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "My Rolldown config",
|
|
6
6
|
"keywords": [
|
|
@@ -23,19 +23,21 @@
|
|
|
23
23
|
"@babel/plugin-syntax-typescript": "^7",
|
|
24
24
|
"@babel/preset-env": "^7",
|
|
25
25
|
"@babel/preset-typescript": "^7",
|
|
26
|
-
"@rollup/plugin-babel": "^
|
|
26
|
+
"@rollup/plugin-babel": "^7",
|
|
27
27
|
"@rollup/plugin-terser": "^0.4.4",
|
|
28
|
-
"@samual/assert": "0.0.1-
|
|
28
|
+
"@samual/assert": "0.0.1-da0fbad",
|
|
29
|
+
"@samual/rolldown-plugin-prettier": "0.0.1-7fd8404",
|
|
29
30
|
"@samual/types": "0.0.2-23ffc7f",
|
|
30
31
|
"babel-plugin-here": "1.0.3-0e10245",
|
|
31
32
|
"babel-plugin-vitest": "0.0.1-7dc1dde",
|
|
32
33
|
"defu": "^6",
|
|
33
|
-
"rolldown": "1.0.0-rc.
|
|
34
|
-
"
|
|
34
|
+
"rolldown": "1.0.0-rc.6",
|
|
35
|
+
"rolldown-plugin-dts": "^0.22.2"
|
|
35
36
|
},
|
|
36
37
|
"pnpm": {
|
|
37
38
|
"patchedDependencies": {
|
|
38
|
-
"defu": "patches/defu.patch"
|
|
39
|
+
"defu": "patches/defu.patch",
|
|
40
|
+
"@types/node": "patches/@types__node.patch"
|
|
39
41
|
}
|
|
40
42
|
},
|
|
41
43
|
"engines": {
|