@samual/rolldown-config 0.0.1-2292609 → 0.0.1-3fd95b2

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.
Files changed (3) hide show
  1. package/default.d.ts +76 -75
  2. package/default.js +20 -16
  3. package/package.json +42 -36
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/lib";
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
- * 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
- }>;
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
- * Construct a {@linkcode RollupOptions} object.
55
- *
56
- * Compiles all `.js` and `.ts` files (excludes `.test.js`, `.test.ts`, and `.d.ts`) found in the
57
- * {@linkcode Options.sourcePath sourcePath}.
58
- *
59
- * @see {@linkcode Options}
60
- *
61
- * @example
62
- * ```text
63
- * src/
64
- * env.d.ts
65
- * foo.ts
66
- * bar/
67
- * baz.ts
68
- * baz.test.ts
69
- * dist/
70
- * foo.js
71
- * bar/
72
- * baz.js
73
- * ```
74
- *
75
- * @example
76
- * ```js
77
- * // rolldown.config.js
78
- * import { rolldownConfig } from "@samual/rolldown-config"
79
- *
80
- * export default rolldownConfig()
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 { ensure } from "@samual/lib/assert"
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 findFiles(sourcePath))
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: Infinity, 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 = ensure(await parseAsync(code, { plugins: [babelPluginSyntaxTypescript] })),
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
- prettier(
76
- defu(prettierOptions, {
77
- parser: "espree",
78
- useTabs: !0,
79
- tabWidth: 4,
80
- arrowParens: "avoid",
81
- printWidth: 120,
82
- semi: !1,
83
- trailingComma: "none"
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,38 +1,44 @@
1
1
  {
2
- "name": "@samual/rolldown-config",
3
- "version": "0.0.1-2292609",
4
- "type": "module",
5
- "description": "My Rolldown config",
6
- "keywords": [
7
- "rolldown",
8
- "config"
9
- ],
10
- "homepage": "https://github.com/samualtnorman/rolldown-config#readme",
11
- "bugs": {
12
- "url": "https://github.com/samualtnorman/rolldown-config/issues",
13
- "email": "me@samual.uk"
14
- },
15
- "license": "MIT",
16
- "author": "Samual Norman <me@samual.uk> (https://samual.uk/)",
17
- "exports": {
18
- ".": "./default.js"
19
- },
20
- "repository": "github:samualtnorman/rolldown-config",
21
- "dependencies": {
22
- "@babel/core": "^7.28.4",
23
- "@babel/plugin-syntax-typescript": "^7.27.1",
24
- "@babel/preset-env": "^7.28.3",
25
- "@babel/preset-typescript": "^7.27.1",
26
- "@rollup/plugin-babel": "^6.1.0",
27
- "@rollup/plugin-terser": "^0.4.4",
28
- "@samual/lib": "0.13.1-5f3d742",
29
- "babel-plugin-here": "1.0.3-d254d5b",
30
- "babel-plugin-vitest": "0.0.1-7dc1dde",
31
- "defu": "^6.1.4",
32
- "rolldown": "1.0.0-beta.44",
33
- "rollup-plugin-prettier": "^4.1.2"
34
- },
35
- "engines": {
36
- "node": "^20.10 || ^22 || >=24"
37
- }
2
+ "name": "@samual/rolldown-config",
3
+ "version": "0.0.1-3fd95b2",
4
+ "type": "module",
5
+ "description": "My Rolldown config",
6
+ "keywords": [
7
+ "rolldown",
8
+ "config"
9
+ ],
10
+ "homepage": "https://github.com/samualtnorman/rolldown-config#readme",
11
+ "bugs": {
12
+ "url": "https://github.com/samualtnorman/rolldown-config/issues",
13
+ "email": "me@samual.uk"
14
+ },
15
+ "license": "MIT",
16
+ "author": "Samual Norman <me@samual.uk> (https://samual.uk/)",
17
+ "exports": {
18
+ ".": "./default.js"
19
+ },
20
+ "repository": "github:samualtnorman/rolldown-config",
21
+ "dependencies": {
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
+ "@rollup/plugin-terser": "^0.4.4",
28
+ "@samual/assert": "0.0.1-fc7f76d",
29
+ "@samual/types": "0.0.2-23ffc7f",
30
+ "babel-plugin-here": "1.0.3-0e10245",
31
+ "babel-plugin-vitest": "0.0.1-7dc1dde",
32
+ "defu": "^6",
33
+ "rolldown": "1.0.0-rc.4",
34
+ "rollup-plugin-prettier": "^4"
35
+ },
36
+ "pnpm": {
37
+ "patchedDependencies": {
38
+ "defu": "patches/defu.patch"
39
+ }
40
+ },
41
+ "engines": {
42
+ "node": "^20.10 || ^22 || >=24"
43
+ }
38
44
  }