prebundle 1.0.0 → 1.0.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/README.md CHANGED
@@ -58,6 +58,18 @@ export default {
58
58
  };
59
59
  ```
60
60
 
61
+ You can also configure `externals` for all packages like this:
62
+
63
+ ```ts
64
+ // prebundle.config.mjs
65
+ export default {
66
+ externals: {
67
+ webpack: '../webpack',
68
+ },
69
+ dependencies: [{ name: 'foo' }, { name: 'foo' }],
70
+ };
71
+ ```
72
+
61
73
  ### minify
62
74
 
63
75
  Whether to minify the code, default `true`.
package/dist/helper.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import type { DependencyConfig, ParsedTask } from './types.js';
1
+ import type { Config, DependencyConfig, ParsedTask } from './types.js';
2
2
  export declare function findDepPath(name: string): string;
3
- export declare const resolveConfig: () => Promise<any>;
3
+ export declare const resolveConfig: () => Promise<Config>;
4
4
  export declare function parseTasks(dependencies: Array<string | DependencyConfig>): 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/index.js CHANGED
@@ -4,6 +4,6 @@ export async function run() {
4
4
  const config = await resolveConfig();
5
5
  const parsedTasks = parseTasks(config.dependencies);
6
6
  for (const task of parsedTasks) {
7
- await prebundle(task);
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): Promise<void>;
2
+ export declare function prebundle(task: ParsedTask, commonExternals: Record<string, string>): Promise<void>;
package/dist/prebundle.js CHANGED
@@ -112,7 +112,7 @@ function renameDistFolder(task) {
112
112
  fs.writeJSONSync(pkgPath, pkgJson);
113
113
  }
114
114
  const pkgName = process.argv[2];
115
- export async function prebundle(task) {
115
+ export async function prebundle(task, commonExternals) {
116
116
  if (pkgName && task.depName !== pkgName) {
117
117
  return;
118
118
  }
@@ -126,6 +126,7 @@ export async function prebundle(task) {
126
126
  target: 'es2019',
127
127
  externals: {
128
128
  ...DEFAULT_EXTERNALS,
129
+ ...commonExternals,
129
130
  ...task.externals,
130
131
  },
131
132
  assetBuilds: false,
package/dist/types.d.ts CHANGED
@@ -19,6 +19,11 @@ export type DependencyConfig = {
19
19
  afterBundle?: (task: ParsedTask) => void | Promise<void>;
20
20
  };
21
21
  export type Config = {
22
+ /**
23
+ * Configure externals for all packages,
24
+ * will be merged with dependencies[i].externals.
25
+ */
26
+ externals: Record<string, string>;
22
27
  dependencies: Array<string | DependencyConfig>;
23
28
  };
24
29
  export type ParsedTask = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prebundle",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "main": "./dist/index.js",
5
5
  "type": "module",
6
6
  "repository": {