bunchee 6.5.4 → 6.6.1
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 +15 -0
- package/dist/bin/cli.js +13 -12
- package/dist/index.js +35 -4
- package/package.json +31 -28
package/README.md
CHANGED
|
@@ -511,6 +511,21 @@ output
|
|
|
511
511
|
export default 'hello world'
|
|
512
512
|
```
|
|
513
513
|
|
|
514
|
+
#### Raw Imports with `?raw` Query
|
|
515
|
+
|
|
516
|
+
You can also import any file as raw text content by adding the `?raw` query parameter to the import statement. This works with any file type:
|
|
517
|
+
|
|
518
|
+
```js
|
|
519
|
+
import readme from './README.md?raw'
|
|
520
|
+
import config from './config.json?raw'
|
|
521
|
+
import styles from './styles.css?raw'
|
|
522
|
+
import content from './data.xml?raw'
|
|
523
|
+
|
|
524
|
+
export { readme, config, styles, content }
|
|
525
|
+
```
|
|
526
|
+
|
|
527
|
+
All these imports will be bundled as string content, regardless of the original file extension.
|
|
528
|
+
|
|
514
529
|
### Node.js API
|
|
515
530
|
|
|
516
531
|
```ts
|
package/dist/bin/cli.js
CHANGED
|
@@ -11,6 +11,7 @@ var index_js = require('../index.js');
|
|
|
11
11
|
require('module');
|
|
12
12
|
var fastGlob = require('fast-glob');
|
|
13
13
|
var prettyBytes = require('pretty-bytes');
|
|
14
|
+
var nanospinner = require('nanospinner');
|
|
14
15
|
|
|
15
16
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
17
|
|
|
@@ -646,7 +647,7 @@ function lint$1(pkg) {
|
|
|
646
647
|
}
|
|
647
648
|
}
|
|
648
649
|
|
|
649
|
-
var version = "6.
|
|
650
|
+
var version = "6.6.0";
|
|
650
651
|
|
|
651
652
|
async function writeDefaultTsconfig(tsConfigPath) {
|
|
652
653
|
await fs.promises.writeFile(tsConfigPath, JSON.stringify(DEFAULT_TS_CONFIG, null, 2), 'utf-8');
|
|
@@ -1008,7 +1009,9 @@ function logOutputState(stats) {
|
|
|
1008
1009
|
const maxFilenameLength = Math.max(...allFileNameLengths);
|
|
1009
1010
|
const statsArray = [
|
|
1010
1011
|
...stats.entries()
|
|
1011
|
-
].
|
|
1012
|
+
]// filter out empty file states.
|
|
1013
|
+
// e.g. if you're building a file that does not listed in the exports, or there's no exports condition.
|
|
1014
|
+
.filter(([, fileStates])=>fileStates.length > 0).sort(([a], [b])=>{
|
|
1012
1015
|
const comp = normalizeExportPath(a).length - normalizeExportPath(b).length;
|
|
1013
1016
|
return comp === 0 ? a.localeCompare(b) : comp;
|
|
1014
1017
|
});
|
|
@@ -1235,15 +1238,13 @@ async function run(args) {
|
|
|
1235
1238
|
const cliEntry = source ? path__default.default.resolve(cwd, source) : '';
|
|
1236
1239
|
// lint package by default
|
|
1237
1240
|
await lint(cwd);
|
|
1238
|
-
const
|
|
1239
|
-
const oraInstance = process.stdout.isTTY ? ora({
|
|
1240
|
-
text: 'Building...\n\n',
|
|
1241
|
+
const spinnerInstance = process.stdout.isTTY ? nanospinner.createSpinner('Building...\n\n', {
|
|
1241
1242
|
color: 'green'
|
|
1242
1243
|
}) : {
|
|
1243
1244
|
start: ()=>{},
|
|
1244
1245
|
stop: ()=>{},
|
|
1245
1246
|
clear: ()=>{},
|
|
1246
|
-
|
|
1247
|
+
success: ()=>{},
|
|
1247
1248
|
isSpinning: false
|
|
1248
1249
|
};
|
|
1249
1250
|
const spinner = {
|
|
@@ -1251,18 +1252,18 @@ async function run(args) {
|
|
|
1251
1252
|
stop: stopSpinner
|
|
1252
1253
|
};
|
|
1253
1254
|
function startSpinner() {
|
|
1254
|
-
|
|
1255
|
+
spinnerInstance.start();
|
|
1255
1256
|
}
|
|
1256
1257
|
function stopSpinner(text) {
|
|
1257
|
-
if (
|
|
1258
|
-
|
|
1258
|
+
if (spinnerInstance.isSpinning) {
|
|
1259
|
+
spinnerInstance.clear();
|
|
1259
1260
|
if (text) {
|
|
1260
|
-
|
|
1261
|
-
|
|
1261
|
+
spinnerInstance.success({
|
|
1262
|
+
mark: '✔',
|
|
1262
1263
|
text
|
|
1263
1264
|
});
|
|
1264
1265
|
} else {
|
|
1265
|
-
|
|
1266
|
+
spinnerInstance.stop();
|
|
1266
1267
|
}
|
|
1267
1268
|
}
|
|
1268
1269
|
}
|
package/dist/index.js
CHANGED
|
@@ -1281,10 +1281,42 @@ function rawContent({ exclude }) {
|
|
|
1281
1281
|
], exclude);
|
|
1282
1282
|
return {
|
|
1283
1283
|
name: 'string',
|
|
1284
|
+
resolveId (id, importer) {
|
|
1285
|
+
// Handle ?raw query parameter
|
|
1286
|
+
if (id.includes('?raw')) {
|
|
1287
|
+
const cleanId = id.split('?')[0];
|
|
1288
|
+
// Resolve the actual file path
|
|
1289
|
+
if (importer) {
|
|
1290
|
+
const path = require('path');
|
|
1291
|
+
return path.resolve(path.dirname(importer), cleanId) + '?raw';
|
|
1292
|
+
}
|
|
1293
|
+
return cleanId + '?raw';
|
|
1294
|
+
}
|
|
1295
|
+
return null;
|
|
1296
|
+
},
|
|
1297
|
+
async load (id) {
|
|
1298
|
+
// Handle ?raw query parameter - read the actual file without the query
|
|
1299
|
+
if (id.includes('?raw')) {
|
|
1300
|
+
const cleanId = id.split('?')[0];
|
|
1301
|
+
try {
|
|
1302
|
+
const content = await fsp.readFile(cleanId, 'utf-8');
|
|
1303
|
+
// Normalize line endings only on Windows: convert \r\n to \n
|
|
1304
|
+
return process.platform === 'win32' ? content.replace(/\r\n/g, '\n') : content;
|
|
1305
|
+
} catch (error) {
|
|
1306
|
+
this.error(`[bunchee] failed to read file: ${cleanId}`);
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
return null;
|
|
1310
|
+
},
|
|
1284
1311
|
transform (code, id) {
|
|
1285
|
-
if
|
|
1312
|
+
// Check if the file has ?raw query parameter
|
|
1313
|
+
const isRawQuery = id.includes('?raw');
|
|
1314
|
+
const cleanId = isRawQuery ? id.split('?')[0] : id;
|
|
1315
|
+
if (filter(cleanId) || isRawQuery) {
|
|
1316
|
+
// Normalize line endings only on Windows for .txt and .data files
|
|
1317
|
+
const normalizedCode = process.platform === 'win32' ? code.replace(/\r\n/g, '\n') : code;
|
|
1286
1318
|
return {
|
|
1287
|
-
code: `const data = ${JSON.stringify(
|
|
1319
|
+
code: `const data = ${JSON.stringify(normalizedCode)};\nexport default data;`,
|
|
1288
1320
|
map: null
|
|
1289
1321
|
};
|
|
1290
1322
|
}
|
|
@@ -1622,8 +1654,7 @@ async function buildInputConfig(entry, bundleConfig, exportCondition, buildConte
|
|
|
1622
1654
|
const hashTo3Char = memoize((input)=>{
|
|
1623
1655
|
let hash = 0;
|
|
1624
1656
|
for(let i = 0; i < input.length; i++){
|
|
1625
|
-
hash = (hash << 5) - hash + input.charCodeAt(i) // Simple hash shift
|
|
1626
|
-
;
|
|
1657
|
+
hash = (hash << 5) - hash + input.charCodeAt(i); // Simple hash shift
|
|
1627
1658
|
}
|
|
1628
1659
|
return (hash >>> 0).toString(36).slice(0, 3) // Base36 + trim to 3 chars
|
|
1629
1660
|
;
|
package/package.json
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bunchee",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.6.1",
|
|
4
4
|
"description": "zero config bundler for js/ts/jsx libraries",
|
|
5
5
|
"bin": "./dist/bin/cli.js",
|
|
6
6
|
"main": "./dist/index.js",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"test": "vitest run",
|
|
10
|
+
"test:update": "TEST_UPDATE_SNAPSHOT=1 pnpm test",
|
|
11
|
+
"test:post": "cross-env POST_BUILD=1 pnpm test test/compile.test.ts test/integration.test.ts",
|
|
12
|
+
"docs:dev": "next dev docs",
|
|
13
|
+
"docs:build": "next build docs",
|
|
14
|
+
"clean": "rm -rf ./dist",
|
|
15
|
+
"new-test": "node ./scripts/new-test.js",
|
|
16
|
+
"typecheck": "tsc --noEmit && tsc -p test/tsconfig.json --noEmit",
|
|
17
|
+
"prepare-release": "pnpm clean && pnpm build",
|
|
18
|
+
"publish-local": "pnpm prepare-release && pnpm test && pnpm publish",
|
|
19
|
+
"prepublishOnly": "pnpm prepare-release && chmod +x ./dist/bin/cli.js",
|
|
20
|
+
"run-ts": "cross-env SWC_NODE_IGNORE_DYNAMIC=1 node -r @swc-node/register",
|
|
21
|
+
"ts-bunchee": "pnpm run-ts ./src/bin/index.ts",
|
|
22
|
+
"build-dir": "pnpm ts-bunchee --cwd",
|
|
23
|
+
"build": "pnpm run-ts ./src/bin/index.ts --runtime node",
|
|
24
|
+
"format": "prettier --write .",
|
|
25
|
+
"prepare": "husky"
|
|
26
|
+
},
|
|
8
27
|
"type": "commonjs",
|
|
9
28
|
"keywords": [
|
|
10
29
|
"bundler",
|
|
@@ -37,24 +56,24 @@
|
|
|
37
56
|
},
|
|
38
57
|
"license": "MIT",
|
|
39
58
|
"dependencies": {
|
|
40
|
-
"@rollup/plugin-commonjs": "^28.0.
|
|
59
|
+
"@rollup/plugin-commonjs": "^28.0.6",
|
|
41
60
|
"@rollup/plugin-json": "^6.1.0",
|
|
42
61
|
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
43
62
|
"@rollup/plugin-replace": "^6.0.2",
|
|
44
63
|
"@rollup/plugin-wasm": "^6.2.2",
|
|
45
64
|
"@rollup/pluginutils": "^5.1.4",
|
|
46
|
-
"@swc/core": "^1.
|
|
47
|
-
"@swc/helpers": "^0.5.
|
|
65
|
+
"@swc/core": "^1.13.3",
|
|
66
|
+
"@swc/helpers": "^0.5.17",
|
|
48
67
|
"clean-css": "^5.3.3",
|
|
49
|
-
"fast-glob": "^3.3.3",
|
|
50
68
|
"magic-string": "^0.30.17",
|
|
51
|
-
"
|
|
69
|
+
"nanospinner": "^1.2.2",
|
|
52
70
|
"picomatch": "^4.0.2",
|
|
53
71
|
"pretty-bytes": "^5.6.0",
|
|
54
|
-
"rollup": "^4.
|
|
55
|
-
"rollup-plugin-dts": "^6.2.
|
|
72
|
+
"rollup": "^4.52.4",
|
|
73
|
+
"rollup-plugin-dts": "^6.2.3",
|
|
56
74
|
"rollup-plugin-swc3": "^0.11.1",
|
|
57
75
|
"rollup-preserve-directives": "^1.1.3",
|
|
76
|
+
"tinyglobby": "^0.2.14",
|
|
58
77
|
"tslib": "^2.8.1",
|
|
59
78
|
"yargs": "^17.7.2"
|
|
60
79
|
},
|
|
@@ -83,34 +102,18 @@
|
|
|
83
102
|
"cross-env": "^7.0.3",
|
|
84
103
|
"husky": "^9.0.11",
|
|
85
104
|
"lint-staged": "^15.2.2",
|
|
86
|
-
"next": "
|
|
105
|
+
"next": "16.0.0-canary.1",
|
|
87
106
|
"picocolors": "^1.0.0",
|
|
88
107
|
"postcss": "^8.5.4",
|
|
89
108
|
"prettier": "3.4.2",
|
|
90
109
|
"react": "^19.0.0",
|
|
91
110
|
"react-dom": "^19.0.0",
|
|
92
111
|
"tailwindcss": "^4.1.8",
|
|
93
|
-
"typescript": "^5.
|
|
112
|
+
"typescript": "^5.9.2",
|
|
94
113
|
"vitest": "^3.0.4"
|
|
95
114
|
},
|
|
96
115
|
"lint-staged": {
|
|
97
116
|
"*.{js,jsx,ts,tsx,md,json,yml,yaml}": "prettier --write"
|
|
98
117
|
},
|
|
99
|
-
"
|
|
100
|
-
|
|
101
|
-
"test:update": "TEST_UPDATE_SNAPSHOT=1 pnpm test",
|
|
102
|
-
"test:post": "cross-env POST_BUILD=1 pnpm test test/compile.test.ts test/integration.test.ts",
|
|
103
|
-
"docs:dev": "next dev docs",
|
|
104
|
-
"docs:build": "next build docs",
|
|
105
|
-
"clean": "rm -rf ./dist",
|
|
106
|
-
"new-test": "node ./scripts/new-test.js",
|
|
107
|
-
"typecheck": "tsc --noEmit && tsc -p test/tsconfig.json --noEmit",
|
|
108
|
-
"prepare-release": "pnpm clean && pnpm build",
|
|
109
|
-
"publish-local": "pnpm prepare-release && pnpm test && pnpm publish",
|
|
110
|
-
"run-ts": "cross-env SWC_NODE_IGNORE_DYNAMIC=1 node -r @swc-node/register",
|
|
111
|
-
"ts-bunchee": "pnpm run-ts ./src/bin/index.ts",
|
|
112
|
-
"build-dir": "pnpm ts-bunchee --cwd",
|
|
113
|
-
"build": "pnpm run-ts ./src/bin/index.ts --runtime node",
|
|
114
|
-
"format": "prettier --write ."
|
|
115
|
-
}
|
|
116
|
-
}
|
|
118
|
+
"packageManager": "pnpm@9.4.0"
|
|
119
|
+
}
|