@hypernym/bundler 0.6.3 → 0.7.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 +1 -1
- package/README.md +26 -2
- package/dist/bin/index.mjs +16 -1
- package/dist/types/index.d.ts +18 -0
- package/package.json +14 -12
package/LICENSE.txt
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2024 Ivo Dolenc, Hypernym Studio
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
package/README.md
CHANGED
|
@@ -259,6 +259,28 @@ export default defineConfig({
|
|
|
259
259
|
})
|
|
260
260
|
```
|
|
261
261
|
|
|
262
|
+
### alias
|
|
263
|
+
|
|
264
|
+
- Type: `true`
|
|
265
|
+
- Default: `undefined`
|
|
266
|
+
|
|
267
|
+
Specifies global path alias support.
|
|
268
|
+
|
|
269
|
+
If true, it enables import prefixes:
|
|
270
|
+
|
|
271
|
+
- `@/*`
|
|
272
|
+
- `~/*`
|
|
273
|
+
|
|
274
|
+
```ts
|
|
275
|
+
// Imports module from './src/utils/index.js'
|
|
276
|
+
import { module } from '@/utils/index.js'
|
|
277
|
+
|
|
278
|
+
// or
|
|
279
|
+
|
|
280
|
+
// Imports module from './src/utils/index.js'
|
|
281
|
+
import { module } from '~/utils/index.js'
|
|
282
|
+
```
|
|
283
|
+
|
|
262
284
|
## CLI
|
|
263
285
|
|
|
264
286
|
### Custom Config
|
|
@@ -271,11 +293,13 @@ npx hyperbundler --config my.config.js
|
|
|
271
293
|
|
|
272
294
|
## Community
|
|
273
295
|
|
|
274
|
-
Feel free to
|
|
296
|
+
Feel free to ask questions or share new ideas.
|
|
297
|
+
|
|
298
|
+
Use the official [discussions](https://github.com/hypernym-studio/bundler/discussions) to get involved.
|
|
275
299
|
|
|
276
300
|
## License
|
|
277
301
|
|
|
278
|
-
Developed in 🇭🇷 Croatia
|
|
302
|
+
Developed in 🇭🇷 Croatia.
|
|
279
303
|
|
|
280
304
|
Released under the [MIT](LICENSE.txt) license.
|
|
281
305
|
|
package/dist/bin/index.mjs
CHANGED
|
@@ -14,6 +14,7 @@ import { getLogFilter } from 'rollup/getLogFilter';
|
|
|
14
14
|
import _replace from '@rollup/plugin-replace';
|
|
15
15
|
import _json from '@rollup/plugin-json';
|
|
16
16
|
import _resolve from '@rollup/plugin-node-resolve';
|
|
17
|
+
import _alias from '@rollup/plugin-alias';
|
|
17
18
|
import { dts } from 'rollup-plugin-dts';
|
|
18
19
|
import { createFilter } from '@rollup/pluginutils';
|
|
19
20
|
|
|
@@ -26,7 +27,7 @@ const externals = [
|
|
|
26
27
|
];
|
|
27
28
|
|
|
28
29
|
const name = "bundler";
|
|
29
|
-
const version = `0.
|
|
30
|
+
const version = `0.7.0`;
|
|
30
31
|
|
|
31
32
|
const cl = console.log;
|
|
32
33
|
const logger = {
|
|
@@ -188,6 +189,7 @@ function esbuild(options) {
|
|
|
188
189
|
const replacePlugin = _replace.default ?? _replace;
|
|
189
190
|
const jsonPlugin = _json.default ?? _json;
|
|
190
191
|
const resolvePlugin = _resolve.default ?? _resolve;
|
|
192
|
+
const aliasPlugin = _alias.default ?? _alias;
|
|
191
193
|
async function build(cwd, options) {
|
|
192
194
|
const { outDir = "dist", hooks } = options;
|
|
193
195
|
let start = 0;
|
|
@@ -201,6 +203,13 @@ async function build(cwd, options) {
|
|
|
201
203
|
await hooks["build:start"](options, buildStats);
|
|
202
204
|
if (options.entries) {
|
|
203
205
|
start = Date.now();
|
|
206
|
+
const aliasDir = `${resolve(cwd, "./src")}/`;
|
|
207
|
+
const aliasOptions = {
|
|
208
|
+
entries: [
|
|
209
|
+
{ find: /^@\//, replacement: aliasDir },
|
|
210
|
+
{ find: /^~\//, replacement: aliasDir }
|
|
211
|
+
]
|
|
212
|
+
};
|
|
204
213
|
for (const entry of options.entries) {
|
|
205
214
|
const entryStart = Date.now();
|
|
206
215
|
let logFilter = getLogFilter(entry.logFilter || []);
|
|
@@ -242,6 +251,9 @@ async function build(cwd, options) {
|
|
|
242
251
|
const resolveOptions = isObject(_entry.pluginsOptions.resolve) ? _entry.pluginsOptions.resolve : void 0;
|
|
243
252
|
_entry.plugins.unshift(resolvePlugin(resolveOptions));
|
|
244
253
|
}
|
|
254
|
+
if (options.alias) {
|
|
255
|
+
_entry.plugins.unshift(aliasPlugin(aliasOptions));
|
|
256
|
+
}
|
|
245
257
|
if (hooks?.["build:entry:start"]) {
|
|
246
258
|
await hooks["build:entry:start"](_entry, buildStats);
|
|
247
259
|
}
|
|
@@ -298,6 +310,9 @@ async function build(cwd, options) {
|
|
|
298
310
|
outro: entry.outro,
|
|
299
311
|
paths: entry.paths
|
|
300
312
|
};
|
|
313
|
+
if (options.alias) {
|
|
314
|
+
_entry.plugins.unshift(aliasPlugin(aliasOptions));
|
|
315
|
+
}
|
|
301
316
|
if (hooks?.["build:entry:start"]) {
|
|
302
317
|
await hooks["build:entry:start"](_entry, buildStats);
|
|
303
318
|
}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -235,6 +235,24 @@ interface Options {
|
|
|
235
235
|
* @default undefined
|
|
236
236
|
*/
|
|
237
237
|
hooks?: HooksOptions;
|
|
238
|
+
/**
|
|
239
|
+
* Specifies global path alias support.
|
|
240
|
+
*
|
|
241
|
+
* If true, it enables import prefixes:
|
|
242
|
+
*
|
|
243
|
+
* - `@/*`
|
|
244
|
+
* - `~/*`
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
*
|
|
248
|
+
* ```ts
|
|
249
|
+
* // Imports module from './src/utils/index.js'
|
|
250
|
+
* import { module } from '@/utils/index.js'
|
|
251
|
+
* ```
|
|
252
|
+
*
|
|
253
|
+
* @default undefined
|
|
254
|
+
*/
|
|
255
|
+
alias?: true;
|
|
238
256
|
}
|
|
239
257
|
|
|
240
258
|
interface BuildLogs {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hypernym/bundler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"author": "Hypernym Studio",
|
|
5
5
|
"description": "ESM & TS module bundler.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -43,6 +43,10 @@
|
|
|
43
43
|
"format": "prettier --config .config/prettier.config.js --write .",
|
|
44
44
|
"prepublishOnly": "npm run build"
|
|
45
45
|
},
|
|
46
|
+
"sideEffects": false,
|
|
47
|
+
"engines": {
|
|
48
|
+
"node": ">=v18.0.0"
|
|
49
|
+
},
|
|
46
50
|
"peerDependencies": {
|
|
47
51
|
"@types/node": ">=20.0.0",
|
|
48
52
|
"typescript": ">=5.0.0"
|
|
@@ -59,25 +63,23 @@
|
|
|
59
63
|
"@hypernym/args": "^0.2.1",
|
|
60
64
|
"@hypernym/colors": "^1.0.1",
|
|
61
65
|
"@hypernym/spinner": "^0.2.0",
|
|
62
|
-
"@hypernym/utils": "^2.
|
|
66
|
+
"@hypernym/utils": "^2.3.0",
|
|
67
|
+
"@rollup/plugin-alias": "^5.1.0",
|
|
63
68
|
"@rollup/plugin-json": "^6.1.0",
|
|
64
69
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
65
70
|
"@rollup/plugin-replace": "^5.0.5",
|
|
66
|
-
"esbuild": "^0.19.
|
|
67
|
-
"rollup": "^4.9.
|
|
71
|
+
"esbuild": "^0.19.11",
|
|
72
|
+
"rollup": "^4.9.5",
|
|
68
73
|
"rollup-plugin-dts": "^6.1.0"
|
|
69
74
|
},
|
|
70
75
|
"devDependencies": {
|
|
71
76
|
"@hypernym/eslint-config": "^2.0.3",
|
|
72
77
|
"@hypernym/prettier-config": "^2.0.3",
|
|
73
|
-
"@hypernym/tsconfig": "^1.
|
|
74
|
-
"@types/node": "^20.
|
|
75
|
-
"eslint": "^8.
|
|
76
|
-
"prettier": "^3.
|
|
77
|
-
"tsx": "^4.
|
|
78
|
+
"@hypernym/tsconfig": "^1.2.0",
|
|
79
|
+
"@types/node": "^20.11.0",
|
|
80
|
+
"eslint": "^8.56.0",
|
|
81
|
+
"prettier": "^3.2.2",
|
|
82
|
+
"tsx": "^4.7.0",
|
|
78
83
|
"typescript": "^5.3.3"
|
|
79
|
-
},
|
|
80
|
-
"engines": {
|
|
81
|
-
"node": ">=v18.0.0"
|
|
82
84
|
}
|
|
83
85
|
}
|