@hypernym/bundler 0.14.3 → 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.
@@ -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,19 +1,24 @@
1
1
  {
2
2
  "name": "@hypernym/bundler",
3
- "version": "0.14.3",
3
+ "version": "0.20.0",
4
4
  "author": "Hypernym Studio",
5
5
  "description": "ESM & TS module bundler.",
6
6
  "license": "MIT",
7
- "repository": "hypernym-studio/bundler",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/hypernym-studio/bundler.git"
10
+ },
8
11
  "homepage": "https://github.com/hypernym-studio/bundler",
9
12
  "funding": "https://github.com/sponsors/ivodolenc",
10
13
  "type": "module",
11
- "types": "./dist/types/index.d.cts",
12
14
  "exports": {
13
15
  ".": {
14
- "types": "./dist/types/index.d.mts",
15
- "import": "./dist/index.mjs",
16
- "require": "./dist/index.cjs"
16
+ "types": "./dist/index.d.mts",
17
+ "import": "./dist/index.mjs"
18
+ },
19
+ "./plugins": {
20
+ "types": "./dist/plugins/index.d.mts",
21
+ "import": "./dist/plugins/index.mjs"
17
22
  }
18
23
  },
19
24
  "files": [
@@ -37,18 +42,6 @@
37
42
  "bin": {
38
43
  "hyperbundler": "./dist/bin/index.mjs"
39
44
  },
40
- "scripts": {
41
- "build": "bun -b run ./src/bin/index.ts",
42
- "lint": "eslint .",
43
- "lint:fix": "eslint --fix .",
44
- "format": "prettier --write .",
45
- "prepublishOnly": "npm run build"
46
- },
47
- "packageManager": "pnpm@10.4.1",
48
- "engines": {
49
- "node": ">=20.0.0",
50
- "pnpm": ">=9.0.0"
51
- },
52
45
  "peerDependencies": {
53
46
  "@types/node": ">=20.0.0",
54
47
  "typescript": ">=5.0.0"
@@ -62,25 +55,25 @@
62
55
  }
63
56
  },
64
57
  "dependencies": {
65
- "@hypernym/args": "^0.3.0",
66
- "@hypernym/colors": "^1.0.2",
67
- "@hypernym/utils": "^3.4.2",
68
- "@rollup/plugin-alias": "^5.1.1",
69
- "@rollup/plugin-json": "^6.1.0",
70
- "@rollup/plugin-node-resolve": "^16.0.0",
71
- "@rollup/plugin-replace": "^6.0.2",
72
- "@rollup/pluginutils": "^5.1.4",
73
- "esbuild": "^0.25.0",
74
- "rollup": "^4.34.8",
75
- "rollup-plugin-dts": "^6.1.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"
76
63
  },
77
64
  "devDependencies": {
78
- "@hypernym/eslint-config": "^3.5.6",
79
- "@hypernym/prettier-config": "^3.2.2",
80
- "@hypernym/tsconfig": "^2.6.0",
81
- "@types/node": "^22.13.5",
82
- "eslint": "^9.21.0",
83
- "prettier": "^3.5.2",
84
- "typescript": "^5.7.3"
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 ."
85
78
  }
86
- }
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;