@hypernym/bundler 0.14.4 → 0.20.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/LICENSE.txt +2 -1
- package/README.md +126 -96
- package/dist/bin/index.mjs +178 -479
- package/dist/build/index.mjs +311 -0
- package/dist/index.d.mts +603 -658
- package/dist/index.mjs +50 -17
- package/dist/plugins/index.d.mts +14 -0
- package/dist/plugins/index.mjs +37 -0
- package/package.json +25 -30
- package/dist/index.cjs +0 -26
- package/dist/index.d.cts +0 -709
package/dist/index.mjs
CHANGED
|
@@ -1,22 +1,55 @@
|
|
|
1
|
+
export * from "./build/index.mjs"
|
|
2
|
+
|
|
3
|
+
//#region src/config.ts
|
|
4
|
+
/**
|
|
5
|
+
* List of global default patterns for external module identifiers.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* ```ts
|
|
10
|
+
* import { externals } from '@hypernym/bundler'
|
|
11
|
+
*
|
|
12
|
+
* export default defineConfig({
|
|
13
|
+
* entries: [
|
|
14
|
+
* {
|
|
15
|
+
* input: './src/index.ts',
|
|
16
|
+
* externals: [...externals, 'id', /regexp/]
|
|
17
|
+
* },
|
|
18
|
+
* ]
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
1
22
|
const externals = [
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
23
|
+
/^node:/,
|
|
24
|
+
/^@types/,
|
|
25
|
+
/^@rollup/,
|
|
26
|
+
/^@rolldown/,
|
|
27
|
+
/^@hypernym/,
|
|
28
|
+
/^rollup/,
|
|
29
|
+
/^rolldown/
|
|
7
30
|
];
|
|
31
|
+
/**
|
|
32
|
+
* ESM & TS module bundler.
|
|
33
|
+
*
|
|
34
|
+
* Automatically detects a custom configuration file at the project root, which can override or extend the build behavior.
|
|
35
|
+
*
|
|
36
|
+
* Configuration file also accepts `.js`, `.mjs`, `.ts`, `.mts` formats.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
*
|
|
40
|
+
* ```ts
|
|
41
|
+
* import { defineConfig } from '@hypernym/bundler'
|
|
42
|
+
*
|
|
43
|
+
* export default defineConfig({
|
|
44
|
+
* // ...
|
|
45
|
+
* })
|
|
46
|
+
* ```
|
|
47
|
+
*
|
|
48
|
+
* @see [Repository](https://github.com/hypernym-studio/bundler)
|
|
49
|
+
*/
|
|
8
50
|
function defineConfig(options) {
|
|
9
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function resolvePaths(options) {
|
|
13
|
-
return (id) => {
|
|
14
|
-
for (const resolver of options) {
|
|
15
|
-
const { find, replacement } = resolver;
|
|
16
|
-
if (id.match(find)) id = replacement;
|
|
17
|
-
}
|
|
18
|
-
return id;
|
|
19
|
-
};
|
|
51
|
+
return options;
|
|
20
52
|
}
|
|
21
53
|
|
|
22
|
-
|
|
54
|
+
//#endregion
|
|
55
|
+
export { defineConfig, externals };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Plugin } from "rolldown";
|
|
2
|
+
export * from "rolldown/experimental";
|
|
3
|
+
export * from "rolldown-plugin-dts";
|
|
4
|
+
|
|
5
|
+
//#region src/plugins/paths/index.d.ts
|
|
6
|
+
declare function outputPaths(entries: OutputPathsEntry[]): Plugin;
|
|
7
|
+
//#endregion
|
|
8
|
+
//#region src/plugins/paths/types.d.ts
|
|
9
|
+
interface OutputPathsEntry {
|
|
10
|
+
find: string | RegExp;
|
|
11
|
+
replacement: string | ((path: string, match: RegExpExecArray | null) => string);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { OutputPathsEntry, outputPaths };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { isString } from "@hypernym/utils";
|
|
2
|
+
|
|
3
|
+
export * from "rolldown/experimental"
|
|
4
|
+
|
|
5
|
+
export * from "rolldown-plugin-dts"
|
|
6
|
+
|
|
7
|
+
//#region src/plugins/paths/index.ts
|
|
8
|
+
function outputPaths(entries) {
|
|
9
|
+
return {
|
|
10
|
+
name: "output-paths",
|
|
11
|
+
renderChunk(code) {
|
|
12
|
+
const patterns = [{
|
|
13
|
+
pattern: /(import|export)([\s\S]*?\bfrom\s*)(['"])([^'"]+)(\3)/g,
|
|
14
|
+
pathIndex: 3
|
|
15
|
+
}, {
|
|
16
|
+
pattern: /(import|require)\s*\(\s*(['"])([^'"]+)(\2)\s*\)/g,
|
|
17
|
+
pathIndex: 2
|
|
18
|
+
}];
|
|
19
|
+
for (const { find, replacement } of entries) {
|
|
20
|
+
const matcher = isString(find) ? new RegExp(find.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g") : new RegExp(find.source, find.flags.includes("g") ? find.flags : find.flags + "g");
|
|
21
|
+
for (const { pattern, pathIndex } of patterns) {
|
|
22
|
+
pattern.lastIndex = 0;
|
|
23
|
+
code = code.replace(pattern, (match, ...groups) => {
|
|
24
|
+
const path = groups[pathIndex];
|
|
25
|
+
matcher.lastIndex = 0;
|
|
26
|
+
const matchResult = matcher.exec(path);
|
|
27
|
+
return matchResult ? match.replace(path, isString(replacement) ? replacement : replacement(path, matchResult)) : match;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return { code };
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { outputPaths };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hypernym/bundler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"author": "Hypernym Studio",
|
|
5
5
|
"description": "ESM & TS module bundler.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -11,12 +11,14 @@
|
|
|
11
11
|
"homepage": "https://github.com/hypernym-studio/bundler",
|
|
12
12
|
"funding": "https://github.com/sponsors/ivodolenc",
|
|
13
13
|
"type": "module",
|
|
14
|
-
"types": "./dist/index.d.cts",
|
|
15
14
|
"exports": {
|
|
16
15
|
".": {
|
|
17
16
|
"types": "./dist/index.d.mts",
|
|
18
|
-
"import": "./dist/index.mjs"
|
|
19
|
-
|
|
17
|
+
"import": "./dist/index.mjs"
|
|
18
|
+
},
|
|
19
|
+
"./plugins": {
|
|
20
|
+
"types": "./dist/plugins/index.d.mts",
|
|
21
|
+
"import": "./dist/plugins/index.mjs"
|
|
20
22
|
}
|
|
21
23
|
},
|
|
22
24
|
"files": [
|
|
@@ -40,13 +42,6 @@
|
|
|
40
42
|
"bin": {
|
|
41
43
|
"hyperbundler": "./dist/bin/index.mjs"
|
|
42
44
|
},
|
|
43
|
-
"scripts": {
|
|
44
|
-
"build": "bun -b run ./src/bin/index.ts",
|
|
45
|
-
"lint": "eslint .",
|
|
46
|
-
"lint:fix": "eslint --fix .",
|
|
47
|
-
"format": "prettier --write .",
|
|
48
|
-
"prepublishOnly": "npm run build"
|
|
49
|
-
},
|
|
50
45
|
"peerDependencies": {
|
|
51
46
|
"@types/node": ">=20.0.0",
|
|
52
47
|
"typescript": ">=5.0.0"
|
|
@@ -60,25 +55,25 @@
|
|
|
60
55
|
}
|
|
61
56
|
},
|
|
62
57
|
"dependencies": {
|
|
63
|
-
"@hypernym/args": "^0.3.
|
|
64
|
-
"@hypernym/colors": "^1.0.
|
|
65
|
-
"@hypernym/utils": "^3.4.
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
69
|
-
"@rollup/plugin-replace": "^6.0.2",
|
|
70
|
-
"@rollup/pluginutils": "^5.1.4",
|
|
71
|
-
"esbuild": "^0.25.4",
|
|
72
|
-
"rollup": "^4.40.2",
|
|
73
|
-
"rollup-plugin-dts": "^6.2.1"
|
|
58
|
+
"@hypernym/args": "^0.3.3",
|
|
59
|
+
"@hypernym/colors": "^1.0.5",
|
|
60
|
+
"@hypernym/utils": "^3.4.5",
|
|
61
|
+
"rolldown": "1.0.0-beta.32",
|
|
62
|
+
"rolldown-plugin-dts": "^0.15.7"
|
|
74
63
|
},
|
|
75
64
|
"devDependencies": {
|
|
76
|
-
"@hypernym/eslint-config": "^3.6.
|
|
77
|
-
"@hypernym/prettier-config": "^3.2.
|
|
78
|
-
"@hypernym/tsconfig": "^2.6.
|
|
79
|
-
"@types/node": "^
|
|
80
|
-
"eslint": "^9.
|
|
81
|
-
"prettier": "^3.
|
|
82
|
-
"typescript": "^5.
|
|
65
|
+
"@hypernym/eslint-config": "^3.6.3",
|
|
66
|
+
"@hypernym/prettier-config": "^3.2.6",
|
|
67
|
+
"@hypernym/tsconfig": "^2.6.2",
|
|
68
|
+
"@types/node": "^24.3.0",
|
|
69
|
+
"eslint": "^9.34.0",
|
|
70
|
+
"prettier": "^3.6.2",
|
|
71
|
+
"typescript": "^5.9.2"
|
|
72
|
+
},
|
|
73
|
+
"scripts": {
|
|
74
|
+
"build": "bun -b run ./src/bin/index.ts",
|
|
75
|
+
"lint": "eslint .",
|
|
76
|
+
"lint:fix": "eslint --fix .",
|
|
77
|
+
"format": "prettier --write ."
|
|
83
78
|
}
|
|
84
|
-
}
|
|
79
|
+
}
|
package/dist/index.cjs
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const externals = [
|
|
4
|
-
/^node:/,
|
|
5
|
-
/^@types/,
|
|
6
|
-
/^@rollup/,
|
|
7
|
-
/^@hypernym/,
|
|
8
|
-
/^rollup/
|
|
9
|
-
];
|
|
10
|
-
function defineConfig(options) {
|
|
11
|
-
return options;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function resolvePaths(options) {
|
|
15
|
-
return (id) => {
|
|
16
|
-
for (const resolver of options) {
|
|
17
|
-
const { find, replacement } = resolver;
|
|
18
|
-
if (id.match(find)) id = replacement;
|
|
19
|
-
}
|
|
20
|
-
return id;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
exports.defineConfig = defineConfig;
|
|
25
|
-
exports.externals = externals;
|
|
26
|
-
exports.resolvePaths = resolvePaths;
|