@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.
- package/index.d.ts +5 -6
- package/index.js +5 -6
- 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
|
-
*
|
|
9
|
+
* @default process.cwd()
|
|
11
10
|
*/
|
|
12
11
|
cwd?: string
|
|
13
12
|
/**
|
|
14
|
-
*
|
|
13
|
+
* Silence sourcemap warnings.
|
|
15
14
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
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 {
|
|
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
|
-
|
|
15
|
-
if (
|
|
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
|
|
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 {
|
|
35
|
+
export { rollupPluginPrettier as default }
|
package/package.json
CHANGED