prebundle 1.2.0 → 1.2.1

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/dist/helper.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Config, DependencyConfig, ParsedTask } from './types.js';
2
2
  export declare function findDepPath(name: string): string | null;
3
3
  export declare const resolveConfig: () => Promise<Config>;
4
- export declare function parseTasks(dependencies: Array<string | DependencyConfig>): ParsedTask[];
4
+ export declare function parseTasks(dependencies: Array<string | DependencyConfig>, globalPrettier?: boolean): ParsedTask[];
5
5
  export declare function pick<T, U extends keyof T>(obj: T, keys: ReadonlyArray<U>): Pick<T, U>;
6
6
  export declare function replaceFileContent(filePath: string, replaceFn: (content: string) => string): void;
package/dist/helper.js CHANGED
@@ -24,7 +24,7 @@ export const resolveConfig = async () => {
24
24
  const config = await import(pathToFileURL(configPath).href);
25
25
  return config.default;
26
26
  };
27
- export function parseTasks(dependencies) {
27
+ export function parseTasks(dependencies, globalPrettier) {
28
28
  const result = [];
29
29
  for (const dep of dependencies) {
30
30
  const depName = typeof dep === 'string' ? dep : dep.name;
@@ -50,6 +50,7 @@ export function parseTasks(dependencies) {
50
50
  dtsExternals: [],
51
51
  emitFiles: [],
52
52
  packageJsonField: [],
53
+ prettier: globalPrettier,
53
54
  ...info,
54
55
  });
55
56
  }
@@ -61,6 +62,7 @@ export function parseTasks(dependencies) {
61
62
  externals: dep.externals ?? {},
62
63
  dtsExternals: dep.dtsExternals ?? [],
63
64
  emitFiles: dep.emitFiles ?? [],
65
+ prettier: dep.prettier ?? globalPrettier,
64
66
  afterBundle: dep.afterBundle,
65
67
  beforeBundle: dep.beforeBundle,
66
68
  packageJsonField: dep.packageJsonField ?? [],
package/dist/index.js CHANGED
@@ -2,8 +2,8 @@ import { parseTasks, resolveConfig } from './helper.js';
2
2
  import { prebundle } from './prebundle.js';
3
3
  export async function run() {
4
4
  const config = await resolveConfig();
5
- const parsedTasks = parseTasks(config.dependencies);
5
+ const parsedTasks = parseTasks(config.dependencies, config.prettier);
6
6
  for (const task of parsedTasks) {
7
- await prebundle(task, config.externals, config.prettier);
7
+ await prebundle(task, config.externals);
8
8
  }
9
9
  }
@@ -1,2 +1,2 @@
1
1
  import type { ParsedTask } from './types.js';
2
- export declare function prebundle(task: ParsedTask, commonExternals?: Record<string, string>, prettier?: boolean): Promise<void>;
2
+ export declare function prebundle(task: ParsedTask, commonExternals?: Record<string, string>): Promise<void>;
package/dist/prebundle.js CHANGED
@@ -167,7 +167,7 @@ function renameDistFolder(task) {
167
167
  fs.writeJSONSync(pkgPath, pkgJson);
168
168
  }
169
169
  const pkgName = process.argv[2];
170
- export async function prebundle(task, commonExternals = {}, prettier) {
170
+ export async function prebundle(task, commonExternals = {}) {
171
171
  if (pkgName && task.depName !== pkgName) {
172
172
  return;
173
173
  }
@@ -187,7 +187,7 @@ export async function prebundle(task, commonExternals = {}, prettier) {
187
187
  externals: mergedExternals,
188
188
  assetBuilds: false,
189
189
  });
190
- await emitIndex(code, task.distPath, prettier);
190
+ await emitIndex(code, task.distPath, task.prettier);
191
191
  emitAssets(assets, task.distPath);
192
192
  await emitDts(task, mergedExternals);
193
193
  emitLicense(task);
package/dist/types.d.ts CHANGED
@@ -11,6 +11,8 @@ export type DependencyConfig = {
11
11
  externals?: Record<string, string>;
12
12
  /** Externals types */
13
13
  dtsExternals?: Array<string | RegExp>;
14
+ /** Whether to prettier the code and strip comments */
15
+ prettier?: boolean;
14
16
  /** Emit extra entry files to map imports. */
15
17
  emitFiles?: ImportMap[];
16
18
  /** Copy extra fields from original package.json to target package.json. */
@@ -38,6 +40,7 @@ export type ParsedTask = {
38
40
  distPath: string;
39
41
  importPath: string;
40
42
  ignoreDts?: boolean;
43
+ prettier?: boolean;
41
44
  target: NonNullable<DependencyConfig['target']>;
42
45
  minify: NonNullable<DependencyConfig['minify']>;
43
46
  depName: NonNullable<DependencyConfig['name']>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prebundle",
3
- "version": "1.2.0",
3
+ "version": "1.2.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/rspack-contrib/prebundle"
@@ -15,12 +15,6 @@
15
15
  "bin.js",
16
16
  "compiled"
17
17
  ],
18
- "scripts": {
19
- "build": "tsc",
20
- "dev": "tsc --watch",
21
- "prebundle": "node ./bin.js",
22
- "prepublishOnly": "npm run build"
23
- },
24
18
  "dependencies": {
25
19
  "@swc/core": "^1.6.13",
26
20
  "@vercel/ncc": "0.38.1",
@@ -36,8 +30,12 @@
36
30
  "rslog": "^1.2.2",
37
31
  "typescript": "^5.4.2"
38
32
  },
39
- "packageManager": "pnpm@9.0.5",
40
33
  "publishConfig": {
41
34
  "registry": "https://registry.npmjs.org/"
35
+ },
36
+ "scripts": {
37
+ "build": "tsc",
38
+ "dev": "tsc --watch",
39
+ "prebundle": "node ./bin.js"
42
40
  }
43
- }
41
+ }