@hypernym/bundler 0.11.0 → 0.12.0
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 +11 -7
- package/dist/bin/index.mjs +8 -8
- package/dist/index.mjs +6 -3
- package/dist/types/index.d.ts +13 -6
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -14,7 +14,9 @@
|
|
|
14
14
|
|
|
15
15
|
<pre align="center">pnpm add -D @hypernym/bundler</pre>
|
|
16
16
|
|
|
17
|
-
<
|
|
17
|
+
<p align="center">
|
|
18
|
+
<strong>Hypernym Studio</strong>
|
|
19
|
+
</p>
|
|
18
20
|
|
|
19
21
|
<br>
|
|
20
22
|
|
|
@@ -443,22 +445,24 @@ export default defineConfig({
|
|
|
443
445
|
|
|
444
446
|
## Utils
|
|
445
447
|
|
|
446
|
-
###
|
|
448
|
+
### resolvePaths
|
|
447
449
|
|
|
448
|
-
- Type: `(
|
|
450
|
+
- Type: `(options: ResolvePathsOptions[]): (id: string) => string`
|
|
449
451
|
|
|
450
|
-
|
|
452
|
+
Resolves external module IDs into custom paths.
|
|
451
453
|
|
|
452
454
|
```ts
|
|
453
|
-
import { defineConfig,
|
|
455
|
+
import { defineConfig, resolvePaths } from '@hypernym/bundler'
|
|
454
456
|
|
|
455
457
|
export default defineConfig({
|
|
456
458
|
entries: [
|
|
457
459
|
{
|
|
458
460
|
input: './src/index.ts',
|
|
459
461
|
externals: [/^@\/path/],
|
|
460
|
-
|
|
461
|
-
|
|
462
|
+
paths: resolvePaths([
|
|
463
|
+
// replaces `@/path` with `./path/index.mjs`
|
|
464
|
+
{ find: /^@\/path/, replacement: './path/index.mjs' },
|
|
465
|
+
]),
|
|
462
466
|
},
|
|
463
467
|
],
|
|
464
468
|
})
|
package/dist/bin/index.mjs
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
import process, { cwd } from 'node:process';
|
|
3
3
|
import { createArgs } from '@hypernym/args';
|
|
4
4
|
import { resolve, dirname, parse } from 'node:path';
|
|
5
|
-
import {
|
|
6
|
-
import { exists, writeFile } from '@hypernym/utils/fs';
|
|
5
|
+
import { read, exists, write, copy, readdir } from '@hypernym/utils/fs';
|
|
7
6
|
import { dim, cyan, bold, green } from '@hypernym/colors';
|
|
8
7
|
import { build as build$1, transform } from 'esbuild';
|
|
8
|
+
import { stat } from 'node:fs/promises';
|
|
9
9
|
import { isString, isObject } from '@hypernym/utils';
|
|
10
10
|
import { rollup } from 'rollup';
|
|
11
11
|
import { getLogFilter } from 'rollup/getLogFilter';
|
|
@@ -27,7 +27,7 @@ const externals = [
|
|
|
27
27
|
const logo = `\u2726\u2726`;
|
|
28
28
|
const name$1 = "hyperbundler";
|
|
29
29
|
const logoname = `${logo} ${name$1}`;
|
|
30
|
-
const version = `0.
|
|
30
|
+
const version = `0.12.0`;
|
|
31
31
|
|
|
32
32
|
const name = logoname.toUpperCase();
|
|
33
33
|
const cl = console.log;
|
|
@@ -98,7 +98,7 @@ async function loadConfig(cwd, filePath, defaults) {
|
|
|
98
98
|
});
|
|
99
99
|
const code = result.outputFiles[0].text;
|
|
100
100
|
const tempConfig = resolve(cwd, "node_modules/.hypernym/bundler/config.mjs");
|
|
101
|
-
await
|
|
101
|
+
await write(tempConfig, code);
|
|
102
102
|
const content = await import(tempConfig);
|
|
103
103
|
const config = {
|
|
104
104
|
...defaults,
|
|
@@ -108,7 +108,7 @@ async function loadConfig(cwd, filePath, defaults) {
|
|
|
108
108
|
}
|
|
109
109
|
async function createConfigLoader(cwd, args) {
|
|
110
110
|
const pkgPath = resolve(cwd, "package.json");
|
|
111
|
-
const pkg = await
|
|
111
|
+
const pkg = await read(pkgPath).catch(error);
|
|
112
112
|
const { dependencies } = JSON.parse(pkg);
|
|
113
113
|
const warnMessage = `Missing required configuration. To start bundling, add the ${cyan(
|
|
114
114
|
`'bundler.config.{js,mjs,ts,mts}'`
|
|
@@ -241,7 +241,7 @@ async function build(cwd, options) {
|
|
|
241
241
|
for (const copyInput of _entry.input) {
|
|
242
242
|
const fileSrc = resolve(cwd, copyInput);
|
|
243
243
|
const fileDist = resolve(cwd, _entry.output, copyInput);
|
|
244
|
-
await
|
|
244
|
+
await copy(fileSrc, fileDist, {
|
|
245
245
|
recursive: _entry.recursive,
|
|
246
246
|
filter: _entry.filter
|
|
247
247
|
}).catch(error);
|
|
@@ -249,7 +249,7 @@ async function build(cwd, options) {
|
|
|
249
249
|
let totalSize = 0;
|
|
250
250
|
if (!stats.isDirectory()) totalSize = stats.size;
|
|
251
251
|
else {
|
|
252
|
-
const files = await readdir(fileDist
|
|
252
|
+
const files = await readdir(fileDist);
|
|
253
253
|
for (const file of files) {
|
|
254
254
|
const filePath = resolve(fileDist, file);
|
|
255
255
|
const fileStat = await stat(filePath);
|
|
@@ -416,7 +416,7 @@ async function build(cwd, options) {
|
|
|
416
416
|
template: entry.template,
|
|
417
417
|
output: entry.output
|
|
418
418
|
};
|
|
419
|
-
await
|
|
419
|
+
await write(_entry.output, _entry.template);
|
|
420
420
|
const stats = await stat(resolve(cwd, _entry.output));
|
|
421
421
|
const fileStats = {
|
|
422
422
|
path: _entry.output,
|
package/dist/index.mjs
CHANGED
|
@@ -9,11 +9,14 @@ function defineConfig(options) {
|
|
|
9
9
|
return options;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
function
|
|
12
|
+
function resolvePaths(options) {
|
|
13
13
|
return (id) => {
|
|
14
|
-
|
|
14
|
+
for (const resolver of options) {
|
|
15
|
+
const { find, replacement } = resolver;
|
|
16
|
+
if (id.match(find)) id = replacement;
|
|
17
|
+
}
|
|
15
18
|
return id;
|
|
16
19
|
};
|
|
17
20
|
}
|
|
18
21
|
|
|
19
|
-
export { defineConfig, externals,
|
|
22
|
+
export { defineConfig, externals, resolvePaths };
|
package/dist/types/index.d.ts
CHANGED
|
@@ -548,25 +548,32 @@ declare const externals: RegExp[];
|
|
|
548
548
|
declare function defineConfig(options: Options): Options;
|
|
549
549
|
|
|
550
550
|
/**
|
|
551
|
-
*
|
|
551
|
+
* Resolves external module IDs into custom paths.
|
|
552
552
|
*
|
|
553
553
|
* @example
|
|
554
554
|
*
|
|
555
555
|
* ```ts
|
|
556
|
-
* import { defineConfig,
|
|
556
|
+
* import { defineConfig, resolvePaths } from '@hypernym/bundler'
|
|
557
557
|
*
|
|
558
558
|
* export default defineConfig({
|
|
559
559
|
* entries: [
|
|
560
560
|
* {
|
|
561
561
|
* input: './src/index.ts',
|
|
562
562
|
* externals: [/^@\/path/],
|
|
563
|
-
*
|
|
564
|
-
*
|
|
563
|
+
* paths: resolvePaths([
|
|
564
|
+
* // replaces `@/path` with `./path/index.mjs`
|
|
565
|
+
* { find: /^@\/path/, replacement: './path/index.mjs', }
|
|
566
|
+
* ]),
|
|
565
567
|
* },
|
|
566
568
|
* ]
|
|
567
569
|
* })
|
|
568
570
|
* ```
|
|
569
571
|
*/
|
|
570
|
-
declare function
|
|
572
|
+
declare function resolvePaths(options: ResolvePathsOptions[]): (id: string) => string;
|
|
571
573
|
|
|
572
|
-
|
|
574
|
+
interface ResolvePathsOptions {
|
|
575
|
+
find: string | RegExp;
|
|
576
|
+
replacement: string;
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
export { type BuildLogs, type BuildStats, type ConfigLoader, type CopyOptions, type EntryBase, type EntryChunk, type EntryCopy, type EntryDeclaration, type EntryOptions, type EntryTemplate, type HooksOptions, type Options, type ResolvePathsOptions, type TransformersChunk, type TransformersDeclaration, defineConfig, externals, resolvePaths };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hypernym/bundler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0",
|
|
4
4
|
"author": "Hypernym Studio",
|
|
5
5
|
"description": "ESM & TS module bundler.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"prepublishOnly": "npm run build"
|
|
46
46
|
},
|
|
47
47
|
"sideEffects": false,
|
|
48
|
-
"packageManager": "pnpm@9.
|
|
48
|
+
"packageManager": "pnpm@9.11.0",
|
|
49
49
|
"engines": {
|
|
50
50
|
"node": ">=20.0.0",
|
|
51
51
|
"pnpm": ">=9.0.0"
|
|
@@ -65,20 +65,20 @@
|
|
|
65
65
|
"dependencies": {
|
|
66
66
|
"@hypernym/args": "^0.3.0",
|
|
67
67
|
"@hypernym/colors": "^1.0.1",
|
|
68
|
-
"@hypernym/utils": "^3.0
|
|
68
|
+
"@hypernym/utils": "^3.4.0",
|
|
69
69
|
"@rollup/plugin-alias": "^5.1.0",
|
|
70
70
|
"@rollup/plugin-json": "^6.1.0",
|
|
71
71
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
72
72
|
"@rollup/plugin-replace": "^5.0.7",
|
|
73
73
|
"@rollup/pluginutils": "^5.1.0",
|
|
74
74
|
"esbuild": "^0.23.1",
|
|
75
|
-
"rollup": "^4.
|
|
75
|
+
"rollup": "^4.22.2",
|
|
76
76
|
"rollup-plugin-dts": "^6.1.1"
|
|
77
77
|
},
|
|
78
78
|
"devDependencies": {
|
|
79
79
|
"@hypernym/eslint-config": "^3.5.0",
|
|
80
80
|
"@hypernym/prettier-config": "^3.2.0",
|
|
81
|
-
"@hypernym/tsconfig": "^2.
|
|
81
|
+
"@hypernym/tsconfig": "^2.4.0",
|
|
82
82
|
"@types/node": "^22.5.5",
|
|
83
83
|
"eslint": "^9.10.0",
|
|
84
84
|
"prettier": "^3.3.3",
|