@visulima/packem 1.0.0-alpha.113 → 1.0.0-alpha.115

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.
Files changed (33) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +72 -22
  3. package/dist/cli.mjs +48 -48
  4. package/dist/config.d.cts +2 -2
  5. package/dist/config.d.mts +2 -2
  6. package/dist/config.d.ts +2 -2
  7. package/dist/create-bundler.cjs +53 -53
  8. package/dist/create-bundler.d.cts +2 -2
  9. package/dist/create-bundler.d.mts +2 -2
  10. package/dist/create-bundler.d.ts +2 -2
  11. package/dist/create-bundler.mjs +46 -46
  12. package/dist/packem_shared/constants-C6PbV8fy.cjs +1 -0
  13. package/dist/packem_shared/{constants-n_OCmkdp.mjs → constants-Oqc_Y1V5.mjs} +1 -1
  14. package/dist/packem_shared/{types-DTkEbU2T.d.mts → types-CsimO7Ks.d.mts} +1 -1
  15. package/dist/packem_shared/{types-CCTimmx3.d.cts → types-DtIVC6bt.d.cts} +1 -1
  16. package/dist/packem_shared/{types-DTP2zyHG.d.ts → types-wdkaYBSv.d.ts} +1 -1
  17. package/dist/rollup/plugins/esbuild/index.cjs +1 -1
  18. package/dist/rollup/plugins/esbuild/index.mjs +1 -1
  19. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.cts +1 -1
  20. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.mts +1 -1
  21. package/dist/rollup/plugins/oxc/isolated-declarations-oxc-transformer.d.ts +1 -1
  22. package/dist/rollup/plugins/sucrase/index.cjs +1 -1
  23. package/dist/rollup/plugins/sucrase/index.mjs +1 -1
  24. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.cts +1 -1
  25. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.mts +1 -1
  26. package/dist/rollup/plugins/swc/isolated-declarations-swc-transformer.d.ts +1 -1
  27. package/dist/rollup/plugins/swc/swc-plugin.cjs +1 -1
  28. package/dist/rollup/plugins/swc/swc-plugin.mjs +1 -1
  29. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.cts +1 -1
  30. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.mts +1 -1
  31. package/dist/rollup/plugins/typescript/isolated-declarations-typescript-transformer.d.ts +1 -1
  32. package/package.json +1 -1
  33. package/dist/packem_shared/constants-BhRby9_z.cjs +0 -1
package/CHANGELOG.md CHANGED
@@ -1,3 +1,23 @@
1
+ ## @visulima/packem [1.0.0-alpha.115](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.114...@visulima/packem@1.0.0-alpha.115) (2024-09-16)
2
+
3
+ ### Bug Fixes
4
+
5
+ * improved external handling of package imports ([39defc9](https://github.com/visulima/packem/commit/39defc9ae6f783bd3a32c2c57143537e05c4af06))
6
+
7
+ ### Miscellaneous Chores
8
+
9
+ * renamed test ([35c7269](https://github.com/visulima/packem/commit/35c726930d6a8af046f5f53bd9deb523d31d7370))
10
+ * renamed test ([4ac1ce0](https://github.com/visulima/packem/commit/4ac1ce0f1567c4b46e3628bfbd441b9f1db06b25))
11
+
12
+ ## @visulima/packem [1.0.0-alpha.114](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.113...@visulima/packem@1.0.0-alpha.114) (2024-09-16)
13
+
14
+ ### Bug Fixes
15
+
16
+ * added Security Policy, added test run on release, updated readme ([c07ea0f](https://github.com/visulima/packem/commit/c07ea0fa7140b83fe8ef13c49afe8ef838034686))
17
+ * fixed tests ([fb69a7b](https://github.com/visulima/packem/commit/fb69a7b98d4498c0844da18e179965f0ee7ca310))
18
+ * fixed tests ([b0558c3](https://github.com/visulima/packem/commit/b0558c3449df4e2322b4b44faf27719b21c2e2ee))
19
+ * renamed variables ([273079e](https://github.com/visulima/packem/commit/273079e1ff802231916ecdd9a047b67e754a2b84))
20
+
1
21
  ## @visulima/packem [1.0.0-alpha.113](https://github.com/visulima/packem/compare/@visulima/packem@1.0.0-alpha.112...@visulima/packem@1.0.0-alpha.113) (2024-09-15)
2
22
 
3
23
  ### Bug Fixes
package/README.md CHANGED
@@ -34,20 +34,24 @@ It uses the `exports` configuration in `package.json` and recognizes entry file
34
34
 
35
35
  ## Features
36
36
 
37
- - ✅ package.json#exports, package.json#main, package.json#module to define entry-points
38
- - ✅ package.json#bin to define executables
39
- - ✅ package.json#types to define types
40
- - ✅ Generates package.json#typeVersions to support node 10
41
- - ✅ Dependency externalization
42
- - ✅ Minification
43
- - ✅ TypeScript support + .d.ts bundling
44
- - ✅ Watch mode
45
- - ✅ CLI outputs (auto hashbang insertion)
46
- - ✅ Validates package.json and checks if all fields that are needed to publish your package are configured correctly
47
- - ✅ Supports multiple runtimes (default, react-server, edge-light)
48
- - ✅ Supports react server and client components
49
- - ✅ Supports shared modules
50
- - ✅ Supports dynamic import
37
+ - ✅ package.json#exports, package.json#main, package.json#module to define entry-points
38
+ - ✅ package.json#bin to define executables
39
+ - ✅ package.json#types to define types
40
+ - ✅ Generates package.json#typeVersions to support node 10
41
+ - ✅ Dependency externalization
42
+ - ✅ Minification
43
+ - ✅ TypeScript support + .d.ts bundling
44
+ - ✅ Watch mode
45
+ - ✅ CLI outputs (auto hashbang insertion)
46
+ - ✅ Validates package.json and checks if all fields that are needed to publish your package are configured correctly
47
+ - ✅ Supports multiple runtimes (default, react-server, edge-light)
48
+ - ✅ Supports react server and client components
49
+ - ✅ Supports shared modules
50
+ - ✅ Supports dynamic import
51
+ - ✅ Supports `tsconfig.json` paths and `package.json` imports resolution
52
+ - ✅ ESM ⇄ CJS interoperability
53
+ - ✅ Supports isolated declaration types (experimental)
54
+ - ✅ Supports wasm [WebAssembly modules](http://webassembly.org)
51
55
 
52
56
  And more...
53
57
 
@@ -237,9 +241,8 @@ For instance:
237
241
 
238
242
  If you need to separate the `production` and `development` exports condition, `packem` provides `process.env.NODE_ENV` injected by default if present that you don't need to manually inject yourself.
239
243
 
240
-
241
- - When the `production` exports condition is defined and the file ends with `*.production.*` in the package.json, the bundle will be minified.
242
- - When the `development` exports condition is defined and the file ends with `*.development.*` in the package.json, the bundle will not be minified.
244
+ - When the `production` exports condition is defined and the file ends with `*.production.*` in the package.json, the bundle will be minified.
245
+ - When the `development` exports condition is defined and the file ends with `*.development.*` in the package.json, the bundle will not be minified.
243
246
 
244
247
  ```json
245
248
  {
@@ -254,8 +257,7 @@ If you need to separate the `production` and `development` exports condition, `p
254
257
 
255
258
  To build executable files with the `bin` field in package.json. The source file matching will be same as the entry files convention.
256
259
 
257
- > [!NOTE]
258
- > `packem` automatically preserves and prepends the shebang to the executable file, and fix correct permissions for the executable file.
260
+ > [!NOTE] > `packem` automatically preserves and prepends the shebang to the executable file, and fix correct permissions for the executable file.
259
261
 
260
262
  For example:
261
263
 
@@ -380,20 +382,68 @@ console.log(text); // "Hello World"
380
382
 
381
383
  #### Visualize Bundle Makeup
382
384
 
383
- Use the `--visualize` flag to generate a `stats.html` file at build time, showing the makeup of your bundle.
385
+ Use the `--visualize` flag to generate a `packem-bundle-analyze.html` file at build time, showing the makeup of your bundle.
384
386
 
385
387
  #### Building Module Workers (Experimental) (WIP)
386
388
 
387
389
  `packem` supports building module workers with the `--workers` flag, which are a special type of bundle that can be used to run code in a web worker.
388
390
 
389
391
  ```js
390
- worker = new Worker(new URL('./worker.js', import.meta.url), { type: 'module' });
392
+ worker = new Worker(new URL("./worker.js", import.meta.url), { type: "module" });
391
393
  // or simply:
392
- worker = new Worker('./worker.js', { type: 'module' });
394
+ worker = new Worker("./worker.js", { type: "module" });
393
395
  ```
394
396
 
395
397
  #### CSS and CSS Modules (Coming Soon)
396
398
 
399
+ ### Aliases
400
+
401
+ Aliases can be configured in the [import map](https://nodejs.org/api/packages.html#imports), defined in `package.json#imports`.
402
+
403
+ For native Node.js import mapping, all entries must be prefixed with `#` to indicate an internal [subpath import](https://nodejs.org/api/packages.html#subpath-imports). `Packem` takes advantage of this behavior to define entries that are _not prefixed_ with `#` as an alias.
404
+
405
+ Native Node.js import mapping supports conditional imports (eg. resolving different paths for Node.js and browser), but `packem` does not.
406
+
407
+ > ⚠️ Aliases are not supported in type declaration generation. If you need type support, do not use aliases.
408
+
409
+ ```json5
410
+ {
411
+ // ...
412
+
413
+ imports: {
414
+ // Mapping '~utils' to './src/utils.js'
415
+ "~utils": "./src/utils.js",
416
+
417
+ // Native Node.js import mapping (can't reference ./src)
418
+ "#internal-package": "./vendors/package/index.js",
419
+ },
420
+ }
421
+ ```
422
+
423
+ ### ESM ⇄ CJS interoperability
424
+
425
+ Node.js ESM offers [interoperability with CommonJS](https://nodejs.org/api/esm.html#interoperability-with-commonjs) via [static analysis](https://github.com/nodejs/cjs-module-lexer). However, not all bundlers compile ESM to CJS syntax in a way that is statically analyzable.
426
+
427
+ Because `packem` uses Rollup, it's able to produce CJS modules that are minimal and interoperable with Node.js ESM.
428
+
429
+ This means you can technically output in CommonJS to get ESM and CommonJS support.
430
+
431
+ #### `require()` in ESM
432
+
433
+ Sometimes it's useful to use `require()` or `require.resolve()` in ESM. ESM code that uses `require()` can be seamlessly compiled to CommonJS, but when compiling to ESM, Node.js will error because `require` doesn't exist in the module scope.
434
+
435
+ When compiling to ESM, `packem` detects `require()` usages and shims it with [`createRequire(import.meta.url)`](https://nodejs.org/api/module.html#modulecreaterequirefilename).
436
+
437
+ ### Environment variables
438
+
439
+ Pass in compile-time environment variables with the `--env` flag.
440
+
441
+ This will replace all instances of `process.env.NODE_ENV` with `'production'` and remove unused code:
442
+
443
+ ```sh
444
+ packem build --env.NODE_ENV=production
445
+ ```
446
+
397
447
  ## Validating
398
448
 
399
449
  `Packem` validates your `package.json` file and checks if all fields are configured correctly, that are needed to publish your package.