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

Feat: generate bundles for "worker" style environement #2589

Closed
wants to merge 0 commits into from

Conversation

nicksrandall
Copy link
Contributor

@nicksrandall nicksrandall commented Dec 10, 2021

What:

This is PR uses a hopefully soon-to-be-released newly released version of preconstruct that support building "worker" compatible builds. The primary use-case for this is to support Cloudflare workers.

Why:
See #2554

How:
I've made changes to each package in the monorepo and extended the package.json to include an "exports" field with custom conditionals for "browser" and "worker".

Checklist:

  • Documentation
  • Tests
  • Code complete
  • Changeset

@changeset-bot
Copy link

changeset-bot bot commented Dec 10, 2021

⚠️ No Changeset found

Latest commit: c9a1195

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Dec 10, 2021

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit c9a1195:

Sandbox Source
Emotion Configuration

@codecov
Copy link

codecov bot commented Dec 10, 2021

@ItsWendell
Copy link
Contributor

This is also super relevant for the Next.js Edge Runtime now (which is essentially built Cloudflare Worker): #2777, #2554

@Andarist Andarist mentioned this pull request Jul 7, 2022
4 tasks
"worker": {
"production": {
"module": "./dist/emotion-cache.worker.esm.prod.js",
"default": "./dist/emotion-cache.worker.cjs.prod.js"

Choose a reason for hiding this comment

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

Why "module" and "default" instead of "import" and "require" as documented here? "module" isn't a standard condition, so "default" will always be used (i.e. no ESM support; always CommonJS).

@nicksrandall
Copy link
Contributor Author

nicksrandall commented Jul 11, 2022

@mitchellhamilton @Andarist I have updated this PR to use the new v2.1.8 version of preconstruct and attempted to build with the new "worker" condition enabled but I must be missing something because that specific condition is not being generated. (The browser condition is working). Any chance you could take a quick look and let me know what I did wrong?

@emmatown
Copy link
Member

envConditoins should be envConditions. Also, could you remove browser & worker builds for things that don't use typeof window or etc. (e.g. memoize but there are some others it looks like). Also, could you set preconstruct.exports to true at the root level so there should only be preconstruct.exports config on packages that need worker & browser builds.

@nicksrandall
Copy link
Contributor Author

Didn't mean to close, re-created in #2819

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.

None yet

4 participants