prebundle 1.1.0-beta.4 → 1.1.0-beta.6

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
@@ -2,7 +2,7 @@
2
2
 
3
3
  Prebundle 3rd party dependencies, output a single js file, a package.json file and the dts files.
4
4
 
5
- Based on [ncc](https://github.com/vercel/ncc) and `dts-packer`.
5
+ Based on [ncc](https://github.com/vercel/ncc) and [rollup-plugin-dts](https://www.npmjs.com/package/rollup-plugin-dts).
6
6
 
7
7
  <p>
8
8
  <a href="https://npmjs.com/package/prebundle">
@@ -4,4 +4,5 @@ export declare const DEFAULT_EXTERNALS: {
4
4
  '../package.json': string;
5
5
  '../../package.json': string;
6
6
  };
7
+ export declare const NODE_BUILTINS: string[];
7
8
  export declare const cwd: string;
package/dist/constant.js CHANGED
@@ -5,4 +5,44 @@ export const DEFAULT_EXTERNALS = {
5
5
  '../package.json': './package.json',
6
6
  '../../package.json': './package.json',
7
7
  };
8
+ export const NODE_BUILTINS = [
9
+ '_stream_duplex',
10
+ '_stream_passthrough',
11
+ '_stream_readable',
12
+ '_stream_transform',
13
+ '_stream_writable',
14
+ 'assert',
15
+ 'buffer',
16
+ 'child_process',
17
+ 'cluster',
18
+ 'console',
19
+ 'constants',
20
+ 'crypto',
21
+ 'dgram',
22
+ 'dns',
23
+ 'domain',
24
+ 'events',
25
+ 'fs',
26
+ 'http',
27
+ 'https',
28
+ 'module',
29
+ 'net',
30
+ 'os',
31
+ 'path',
32
+ 'process',
33
+ 'punycode',
34
+ 'querystring',
35
+ 'readline',
36
+ 'repl',
37
+ 'stream',
38
+ 'string_decoder',
39
+ 'sys',
40
+ 'timers',
41
+ 'tls',
42
+ 'tty',
43
+ 'url',
44
+ 'util',
45
+ 'vm',
46
+ 'zlib',
47
+ ];
8
48
  export const cwd = process.cwd();
package/dist/helper.js CHANGED
@@ -2,6 +2,7 @@ import { dirname, join } from 'node:path';
2
2
  import fs from '../compiled/fs-extra/index.js';
3
3
  import { cwd, DIST_DIR } from './constant.js';
4
4
  import { createRequire } from 'node:module';
5
+ import { pathToFileURL } from 'node:url';
5
6
  const require = createRequire(import.meta.url);
6
7
  export function findDepPath(name) {
7
8
  try {
@@ -20,7 +21,7 @@ export function findDepPath(name) {
20
21
  }
21
22
  export const resolveConfig = async () => {
22
23
  const configPath = join(cwd, 'prebundle.config.mjs');
23
- const config = await import(configPath);
24
+ const config = await import(pathToFileURL(configPath).href);
24
25
  return config.default;
25
26
  };
26
27
  export function parseTasks(dependencies) {
package/dist/prebundle.js CHANGED
@@ -1,9 +1,9 @@
1
- import { join } from 'node:path';
1
+ import { dirname, join } from 'node:path';
2
2
  import ncc from '@vercel/ncc';
3
3
  import fastGlob from '../compiled/fast-glob/index.js';
4
4
  import fs from '../compiled/fs-extra/index.js';
5
5
  import rslog from '../compiled/rslog/index.js';
6
- import { DEFAULT_EXTERNALS } from './constant.js';
6
+ import { DEFAULT_EXTERNALS, NODE_BUILTINS } from './constant.js';
7
7
  import { findDepPath, pick } from './helper.js';
8
8
  import { dts } from 'rollup-plugin-dts';
9
9
  import { rollup } from 'rollup';
@@ -34,16 +34,13 @@ async function emitDts(task, externals) {
34
34
  if (types) {
35
35
  return join(task.depPath, types);
36
36
  }
37
- const depTypesPath = findDepPath(`@types/${task.depName}`);
37
+ const depTypesPath = findDepPath(`@types/${task.depName}/package.json`);
38
38
  if (!depTypesPath) {
39
39
  return null;
40
40
  }
41
- const depTypesPkgPath = join(depTypesPath, 'package.json');
42
- if (fs.existsSync(depTypesPkgPath)) {
43
- const depTypesPkg = fs.readJsonSync(depTypesPkgPath, 'utf-8');
44
- return getTypes(depTypesPkg);
45
- }
46
- return null;
41
+ const depTypesPkg = fs.readJsonSync(depTypesPath, 'utf-8');
42
+ const depTypes = getTypes(depTypesPkg);
43
+ return depTypes ? join(dirname(depTypesPath), depTypes) : null;
47
44
  };
48
45
  const input = getInput();
49
46
  if (!input) {
@@ -53,7 +50,7 @@ async function emitDts(task, externals) {
53
50
  try {
54
51
  const inputConfig = {
55
52
  input,
56
- external: Object.keys(externals),
53
+ external: [...Object.keys(externals), ...NODE_BUILTINS],
57
54
  plugins: [
58
55
  dts({
59
56
  respectExternal: true,
@@ -155,7 +152,7 @@ export async function prebundle(task, commonExternals = {}) {
155
152
  if (pkgName && task.depName !== pkgName) {
156
153
  return;
157
154
  }
158
- logger.info(`prebundle: ${task.depName}`);
155
+ logger.start(`prebundle: ${task.depName}`);
159
156
  fs.removeSync(task.distPath);
160
157
  if (task.beforeBundle) {
161
158
  await task.beforeBundle(task);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prebundle",
3
- "version": "1.1.0-beta.4",
3
+ "version": "1.1.0-beta.6",
4
4
  "main": "./dist/index.js",
5
5
  "type": "module",
6
6
  "repository": {