bunchee 3.4.0 → 3.4.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 CHANGED
@@ -61,7 +61,10 @@ Using pure ESM package?
61
61
  }
62
62
  ```
63
63
 
64
- Then just run `npm run build`, or `pnpm build` / `yarn build` if you're using these package managers.
64
+ Then just run `npm run build`, or `pnpm build` / `yarn build` if you're using these package managers. The output format will based on the exports condition and also the file extension. Given an example:
65
+
66
+ * It's CommonJS for `require` and ESM for `import` based on the exports condition.
67
+ * It's CommonJS for `.js` and ESM for `.mjs` based on the extension regardless the exports condition. Then for export condition like "node" you could choose the format with your extension.
65
68
 
66
69
  ## Configuration
67
70
 
@@ -121,7 +124,6 @@ bunchee --env=ENV1,ENV2,ENV3
121
124
 
122
125
  Replace `ENV1`, `ENV2`, and `ENV3` with the names of the environment variables you want to include in your bundled code. These environment variables will be inlined during the bundling process.
123
126
 
124
-
125
127
  ### Entry Files Convention
126
128
 
127
129
  While `exports` field is becoming the standard of exporting in node.js, bunchee also supports to build multiple exports all in one command.
@@ -161,6 +163,35 @@ Then you need to add two entry files `index.ts` and `lite.ts` in project root di
161
163
  |- package.json
162
164
  ```
163
165
 
166
+ It will also look up for `index.<ext>` file under the directory having the name of the export path. For example, if you have `"./lite": "./dist/lite.js"` in exports field, then it will look up for `./lite/index.js` as the entry file as well.
167
+
168
+ ### Special Exports Conventions
169
+
170
+ For exports condition like `react-native`, `react-server` and `edge-light` as they're special platforms, they could have different exports or different code conditions. In this case bunchee provides an override input source file convention if you want to build them as different code bundle.
171
+
172
+ For instance:
173
+
174
+ ```json
175
+ {
176
+ "exports": {
177
+ "react-server": "./dist/react-server.mjs",
178
+ "edge-light": "./dist/edge-light.mjs",
179
+ "import": "./dist/index.mjs"
180
+ }
181
+ }
182
+ ```
183
+
184
+ You can use `index.<export-type>.<ext>` to override the input source file for specific export name. Or using `<export-path>/index.<export-type>.<ext>` also works. Such as:
185
+
186
+ ```
187
+ |- src/
188
+ |- index/.ts
189
+ |- index.react-server.ts
190
+ |- index.edge-light.ts
191
+ ```
192
+
193
+ This will match the export name `"react-server"` and `"edge-light"` then use the corresponding input source file to build the bundle.
194
+
164
195
  #### Package lint
165
196
 
166
197
  `bunchee` has support for checking the package bundles are matched with package exports configuration.
package/dist/cli.js CHANGED
@@ -97,7 +97,7 @@ function _fileExists() {
97
97
  return _fileExists.apply(this, arguments);
98
98
  }
99
99
 
100
- var version = "3.4.0";
100
+ var version = "3.4.1";
101
101
 
102
102
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
103
103
  try {
package/dist/index.js CHANGED
@@ -665,16 +665,21 @@ function _buildEntryConfig() {
665
665
  Object.keys(exportPaths).forEach(/*#__PURE__*/ _async_to_generator$2(function*(entryExport) {
666
666
  // TODO: improve the source detection
667
667
  const exportCond = exportPaths[entryExport];
668
- const hasEdgeLight = !!exportCond['edge-light'];
669
- const hasReactServer = !!exportCond['react-server'];
670
668
  const buildConfigs = [
671
669
  createBuildConfig('', exportCond) // default config
672
670
  ];
673
- if (hasEdgeLight) {
674
- buildConfigs.push(createBuildConfig('edge-light', exportCond));
675
- }
676
- if (hasReactServer) {
677
- buildConfigs.push(createBuildConfig('react-server', exportCond));
671
+ // For dts job, only build the default config.
672
+ // For assets job, build all configs.
673
+ if (!dts) {
674
+ if (exportCond['edge-light']) {
675
+ buildConfigs.push(createBuildConfig('edge-light', exportCond));
676
+ }
677
+ if (exportCond['react-server']) {
678
+ buildConfigs.push(createBuildConfig('react-server', exportCond));
679
+ }
680
+ if (exportCond['react-native']) {
681
+ buildConfigs.push(createBuildConfig('react-native', exportCond));
682
+ }
678
683
  }
679
684
  function createBuildConfig(exportType, exportCondRef) {
680
685
  return _createBuildConfig.apply(this, arguments);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bunchee",
3
- "version": "3.4.0",
3
+ "version": "3.4.1",
4
4
  "description": "zero config bundler for js/ts/jsx libraries",
5
5
  "bin": {
6
6
  "bunchee": "./dist/cli.js"