@samual/rolldown-plugin-prettier 0.0.1-7fd8404 → 0.0.1-b9dd910

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/index.d.ts +5 -6
  2. package/index.js +5 -6
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -2,19 +2,18 @@ import { Options as Options$1 } from "prettier"
2
2
  import { Plugin } from "rolldown"
3
3
 
4
4
  //#region src/index.d.ts
5
- declare const NAME = "rolldown-plugin-prettier"
6
5
  interface Options extends Options$1 {
7
6
  /**
8
7
  * Directory to look for a Prettier config file.
9
8
  *
10
- * If omitted, defaults to `process.cwd()`.
9
+ * @default process.cwd()
11
10
  */
12
11
  cwd?: string
13
12
  /**
14
- * Whether to generate a sourcemap.
13
+ * Silence sourcemap warnings.
15
14
  *
16
- * Note: This may take some time because rollup-plugin-prettier diffs the
17
- * output to manually generate a sourcemap.
15
+ * Doesn't do anything if set to a boolean as Rolldown's own `output.sourcemap` decides if a sourcemap is generated.
16
+ * This behaviour matches [`rollup-plugin-prettier`](https://github.com/mjeanroy/rollup-plugin-prettier).
18
17
  */
19
18
  sourcemap?: boolean | "silent"
20
19
  }
@@ -29,4 +28,4 @@ declare namespace rollupPluginPrettier {
29
28
  */
30
29
  declare function rollupPluginPrettier(options: Options): Plugin
31
30
  //#endregion
32
- export { NAME, Options, rollupPluginPrettier as default }
31
+ export { Options, rollupPluginPrettier as default }
package/index.js CHANGED
@@ -10,16 +10,15 @@ function rollupPluginPrettier(options) {
10
10
  const prettierConfig = await prettier.resolveConfig(path.join(options.cwd ?? process.cwd())),
11
11
  { sourcemap, cwd, ...prettierOptions } = options,
12
12
  mergedOptions = { ...prettierConfig, ...prettierOptions },
13
- output = await prettier.format(source, Reflect.ownKeys(mergedOptions).length ? mergedOptions : void 0),
14
- defaultSourcemap = options.sourcemap ?? !1
15
- if (!(outputOptions?.sourcemap ?? defaultSourcemap)) return { code: output }
16
- if ("silent" !== defaultSourcemap) {
13
+ output = await prettier.format(source, Reflect.ownKeys(mergedOptions).length ? mergedOptions : void 0)
14
+ if (!outputOptions.sourcemap) return { code: output }
15
+ if ("silent" != options.sourcemap) {
17
16
  console.warn(`[${NAME}] Sourcemap is enabled, computing diff is required`)
18
17
  console.warn(`[${NAME}] This may take a moment (depends on the size of your bundle)`)
19
18
  }
20
19
  const magicString = new MagicString(source),
21
20
  changes = diffChars(source, output)
22
- if (changes && changes.length > 0) {
21
+ if (changes.length) {
23
22
  let idx = 0
24
23
  changes.forEach(part => {
25
24
  if (part.added) {
@@ -33,4 +32,4 @@ function rollupPluginPrettier(options) {
33
32
  }
34
33
  }
35
34
  }
36
- export { NAME, rollupPluginPrettier as default }
35
+ export { rollupPluginPrettier as default }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@samual/rolldown-plugin-prettier",
3
- "version": "0.0.1-7fd8404",
3
+ "version": "0.0.1-b9dd910",
4
4
  "description": "Rolldown plugin for code formatting using Prettier",
5
5
  "author": "Mickael Jeanroy <mickael.jeanroy@gmail.com>",
6
6
  "contributors": [