Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Output .mjs for hybrid packages #1508

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from
Draft

WIP: Output .mjs for hybrid packages #1508

wants to merge 10 commits into from

Conversation

72636c
Copy link
Member

@72636c 72636c commented Mar 26, 2024

Snapshots via cjs-mjs-output tag: https://www.npmjs.com/package/skuba?activeTab=versions

npm i skuba@cjs-mjs-output

This is an experimental feature that currently requires:

package.json

  {
    "files": [
      "lib*/**/*.d.ts",
      "lib*/**/*.js",
      "lib*/**/*.js.map",
+     "lib*/**/*.mjs",
+     "lib*/**/*.mjs.map"
    ],
-   "main": "./lib-commonjs/index.js",
+   "main": "./lib/index.js",
-   "module": "./lib-es2015/index.js",
+   "module": "./lib/index.mjs",
-   "types": "./lib-types/index.d.ts",
+   "types": "./lib/index.d.ts",
    "scripts": {
      "build": "skuba build-package"
    },
    "skuba": {
+     "build": "esbuild",
      "version": "x.x.x"
    },
  }

To do:

  • Consider forcing declaration and removeComments in this mode, in pursuit of zero config
  • Is this our chance to get rid of build-package as a separate command? It may be better to consolidate on build with support for configuration; we can set package.json#/skuba/build to esbuild today, and we could add an option for e.g. hybrid output.
  • How do we migrate existing packages off their tsc-based lib-commonjs and lib-es2015 output? How safe will it be to switch to esbuild and modern targets?
  • Should we investigate skuba lint autofixes or a skuba migrate for ^?

Copy link

changeset-bot bot commented Mar 26, 2024

⚠️ No Changeset found

Latest commit: 2c2b04b

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@72636c 72636c changed the title WIP: Output .cjs + .mjs for hybrid packages WIP: Output .mjs for hybrid packages Mar 26, 2024
Comment on lines +49 to +56
await runBuild({
bundle: true,
compilerOptions: {
...compilerOptions,
module: ModuleKind.ESNext,
},
debug,
entryPoints,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these entryPoints are not correct for bundle: true. Strictly speaking it should only output the root lib/index.mjs unless more exports are defined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant