prepare-package 2.0.6 → 2.0.8
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 +14 -0
- package/dist/index.js +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -109,6 +109,7 @@ Uses esbuild to produce optimized builds in multiple module formats.
|
|
|
109
109
|
| `build.platform` | `"neutral"` | esbuild platform |
|
|
110
110
|
| `build.external` | `[]` | Packages to exclude from bundle |
|
|
111
111
|
| `build.sourcemap` | `false` | Generate source maps |
|
|
112
|
+
| `build.cjs.footer` | `"module.exports=module.exports.default\|\|module.exports;"` | CJS footer — unwraps `export default` so `require()` returns the value directly |
|
|
112
113
|
| `build.iife.globalName` | — | **Required** when `"iife"` is in formats. The global variable name (e.g., `window.MyLib`) |
|
|
113
114
|
| `build.iife.fileName` | `"{name}.min.js"` | Output filename for IIFE build |
|
|
114
115
|
| `build.iife.target` | `"es2015"` | esbuild target for IIFE build |
|
|
@@ -123,6 +124,19 @@ Uses esbuild to produce optimized builds in multiple module formats.
|
|
|
123
124
|
#### Version replacement
|
|
124
125
|
In bundle mode, all occurrences of `{version}` in `.js` source files are replaced with the version from `package.json` at build time via an esbuild plugin.
|
|
125
126
|
|
|
127
|
+
#### CJS default export
|
|
128
|
+
The CJS build automatically appends a footer that unwraps `export default` so `require('your-package')` returns the function/class directly — not `{ default: fn }`. This means both of these just work:
|
|
129
|
+
|
|
130
|
+
```js
|
|
131
|
+
// ESM
|
|
132
|
+
import MyLib from 'your-package';
|
|
133
|
+
|
|
134
|
+
// CJS
|
|
135
|
+
const MyLib = require('your-package');
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
To override the footer, set `build.cjs.footer` in your config.
|
|
139
|
+
|
|
126
140
|
#### IIFE global export
|
|
127
141
|
The IIFE build automatically unwraps the default export so `window[globalName]` is the class/function directly, not a `{ default }` wrapper.
|
|
128
142
|
|
package/dist/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prepare-package",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "Prepare a Node.js package before being published",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -48,9 +48,9 @@
|
|
|
48
48
|
"dependencies": {
|
|
49
49
|
"chalk": "^5.6.2",
|
|
50
50
|
"chokidar": "^5.0.0",
|
|
51
|
-
"esbuild": "^0.
|
|
51
|
+
"esbuild": "^0.28.0",
|
|
52
52
|
"fs-jetpack": "^5.1.0",
|
|
53
|
-
"wonderful-fetch": "^2.0.
|
|
53
|
+
"wonderful-fetch": "^2.0.5"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"mocha": "^11.7.5"
|