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

build: export CJS #3561

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

build: export CJS #3561

wants to merge 11 commits into from

Conversation

holic
Copy link
Member

@holic holic commented Feb 4, 2025

diff best viewed with https://github.com/latticexyz/mud/pull/3561/files?w=1

  • enabled CJS builds across all packages
  • wrapped top-level awaits in a self-invoking function since top-level await isn't supported in CJS
  • added CJS exports to package.json

TODO

  • tests to catch issues with downstream ESM imports from CJS build
  • maybe split CJS and ESM build configs? this will need a separate dist dir for each

Copy link

changeset-bot bot commented Feb 4, 2025

🦋 Changeset detected

Latest commit: 665b34e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
@latticexyz/abi-ts Patch
@latticexyz/block-logs-stream Patch
@latticexyz/cli Patch
@latticexyz/common Patch
@latticexyz/config Patch
create-mud Patch
@latticexyz/dev-tools Patch
@latticexyz/entrykit Patch
@latticexyz/explorer Patch
@latticexyz/faucet Patch
@latticexyz/gas-report Patch
@latticexyz/protocol-parser Patch
@latticexyz/react Patch
@latticexyz/recs Patch
@latticexyz/schema-type Patch
solhint-config-mud Patch
solhint-plugin-mud Patch
@latticexyz/stash Patch
@latticexyz/store-indexer Patch
@latticexyz/store-sync Patch
@latticexyz/store Patch
@latticexyz/utils Patch
vite-plugin-mud Patch
@latticexyz/world-module-callwithsignature Patch
@latticexyz/world-module-erc20 Patch
@latticexyz/world-module-metadata Patch
@latticexyz/world-modules Patch
@latticexyz/world Patch
@latticexyz/paymaster Patch
@latticexyz/store-consumer Patch

Not sure what this means? Click here to learn what changesets are.

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

@holic
Copy link
Member Author

holic commented Feb 4, 2025

need to figure out this

@latticexyz/explorer:build: CJS Build start
@latticexyz/explorer:build:
@latticexyz/explorer:build:  WARN  ▲ [WARNING] "import.meta" is not available with the "cjs" output format and will be empty [empty-import-meta]
@latticexyz/explorer:build:
@latticexyz/explorer:build:     src/bin/explorer.ts:11:33:
@latticexyz/explorer:build:       11 │ const __filename = fileURLToPath(import.meta.url);
@latticexyz/explorer:build:          ╵                                  ~~~~~~~~~~~
@latticexyz/explorer:build:
@latticexyz/explorer:build:   You need to set the output format to "esm" for "import.meta" to work correctly.
@latticexyz/explorer:build:

possible option: https://tsup.egoist.dev/#inject-cjs-and-esm-shims

@holic holic marked this pull request as ready for review February 4, 2025 16:44
@holic holic requested review from alvrs and karooolis as code owners February 4, 2025 16:44
@holic
Copy link
Member Author

holic commented Feb 5, 2025

need to check if we need https://tsup.egoist.dev/#interop-with-commonjs

@holic
Copy link
Member Author

holic commented Feb 5, 2025

need to add tests as apparently this doesn't solve for deps that are ESM only (change-case for example)

@holic holic mentioned this pull request Feb 5, 2025
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