prebundle 1.0.1 → 1.0.3

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.
@@ -1,2 +1,2 @@
1
1
  import type { ParsedTask } from './types.js';
2
- export declare function prebundle(task: ParsedTask, commonExternals: Record<string, string>): Promise<void>;
2
+ export declare function prebundle(task: ParsedTask, commonExternals?: Record<string, string>): Promise<void>;
package/dist/prebundle.js CHANGED
@@ -25,16 +25,12 @@ function fixTypeExternalPath(file, task, externals) {
25
25
  return newContent;
26
26
  });
27
27
  }
28
- function emitDts(task) {
28
+ function emitDts(task, externals) {
29
29
  if (task.ignoreDts) {
30
30
  fs.writeFileSync(join(task.distPath, 'index.d.ts'), 'export = any;\n');
31
31
  return;
32
32
  }
33
33
  try {
34
- const externals = {
35
- ...DEFAULT_EXTERNALS,
36
- ...task.externals,
37
- };
38
34
  const { files } = new DtsPacker({
39
35
  cwd,
40
36
  name: task.depName,
@@ -112,7 +108,7 @@ function renameDistFolder(task) {
112
108
  fs.writeJSONSync(pkgPath, pkgJson);
113
109
  }
114
110
  const pkgName = process.argv[2];
115
- export async function prebundle(task, commonExternals) {
111
+ export async function prebundle(task, commonExternals = {}) {
116
112
  if (pkgName && task.depName !== pkgName) {
117
113
  return;
118
114
  }
@@ -121,19 +117,20 @@ export async function prebundle(task, commonExternals) {
121
117
  if (task.beforeBundle) {
122
118
  await task.beforeBundle(task);
123
119
  }
120
+ const mergedExternals = {
121
+ ...DEFAULT_EXTERNALS,
122
+ ...commonExternals,
123
+ ...task.externals,
124
+ };
124
125
  const { code, assets } = await ncc(task.depEntry, {
125
126
  minify: task.minify,
126
127
  target: 'es2019',
127
- externals: {
128
- ...DEFAULT_EXTERNALS,
129
- ...commonExternals,
130
- ...task.externals,
131
- },
128
+ externals: mergedExternals,
132
129
  assetBuilds: false,
133
130
  });
134
131
  emitIndex(code, task.distPath);
135
132
  emitAssets(assets, task.distPath);
136
- emitDts(task);
133
+ emitDts(task, mergedExternals);
137
134
  emitLicense(task);
138
135
  emitPackageJson(task);
139
136
  removeSourceMap(task);
package/dist/types.d.ts CHANGED
@@ -23,7 +23,7 @@ export type Config = {
23
23
  * Configure externals for all packages,
24
24
  * will be merged with dependencies[i].externals.
25
25
  */
26
- externals: Record<string, string>;
26
+ externals?: Record<string, string>;
27
27
  dependencies: Array<string | DependencyConfig>;
28
28
  };
29
29
  export type ParsedTask = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prebundle",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "main": "./dist/index.js",
5
5
  "type": "module",
6
6
  "repository": {