-
Notifications
You must be signed in to change notification settings - Fork 955
[vite-plugin]: fix applications not being able to import assets from dependencies #8672
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
Conversation
🦋 Changeset detectedLatest commit: 198b521 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
packages/vite-plugin-cloudflare/src/runner-worker/module-runner.ts
Outdated
Show resolved
Hide resolved
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14196721824/npm-package-wrangler-8672 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/8672/npm-package-wrangler-8672 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14196721824/npm-package-wrangler-8672 dev path/to/script.js Additional artifacts:cloudflare-workers-bindings-extension: wget https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14196721824/npm-package-cloudflare-workers-bindings-extension-8672 -O ./cloudflare-workers-bindings-extension.0.0.0-vb7a0a645e.vsix && code --install-extension ./cloudflare-workers-bindings-extension.0.0.0-vb7a0a645e.vsix create-cloudflare: npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14196721824/npm-package-create-cloudflare-8672 --no-auto-update @cloudflare/kv-asset-handler: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14196721824/npm-package-cloudflare-kv-asset-handler-8672 miniflare: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14196721824/npm-package-miniflare-8672 @cloudflare/pages-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14196721824/npm-package-cloudflare-pages-shared-8672 @cloudflare/unenv-preset: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14196721824/npm-package-cloudflare-unenv-preset-8672 @cloudflare/vite-plugin: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14196721824/npm-package-cloudflare-vite-plugin-8672 @cloudflare/vitest-pool-workers: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14196721824/npm-package-cloudflare-vitest-pool-workers-8672 @cloudflare/workers-editor-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14196721824/npm-package-cloudflare-workers-editor-shared-8672 @cloudflare/workers-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14196721824/npm-package-cloudflare-workers-shared-8672 @cloudflare/workflows-shared: npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/14196721824/npm-package-cloudflare-workflows-shared-8672 Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
As part of this PR, should we also error/warn in |
I'm totally happy to implement that too, but I don't think it needs to be part of this PR? (my personal preference is to keep PRs small and scoped so that they are easier to write, review and look up in the future) |
Sure. I mentioned it now because I kind of feel that |
I see, but I think that we should have both checks, the ones in (basically the way I see it is that the ones in the module runner are the "real" checks while other checks would be more for DX purposes than anything else) do you think this would be overkill? |
I think we should go with the simplest solution and error as early as possible. That's why I prefer my suggestion of validating the resolved config. I feel the logic in |
I'm happy to go with your solution and change it if/when needed 👍 |
b1af5ed
to
97873ca
Compare
Note, I was working an adding an e2e test to make sure the validation takes place, but the e2es seem not to currently fully work as intended, changes in #8688 should fix them, so I can add those after that PR is merged (or do it in a followup PR) |
4f0ea60
to
8c9bc7d
Compare
abf5851
to
75453ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Just a few minor comments.
I did also wonder if we should validate resolve.noExternal
to check it's always true
? We may also want to check that optimizeDeps.noDiscovery
is false
but we can't do that until this PR is released - remix-run/react-router#13317. We could add both of these together in a future PR if you prefer.
packages/vite-plugin-cloudflare/src/worker-environments-validation.ts
Outdated
Show resolved
Hide resolved
packages/vite-plugin-cloudflare/src/worker-environments-validation.ts
Outdated
Show resolved
Hide resolved
packages/vite-plugin-cloudflare/src/worker-environments-validation.ts
Outdated
Show resolved
Hide resolved
packages/vite-plugin-cloudflare/src/worker-environments-validation.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: James Opstad <13586373+jamesopstad@users.noreply.github.com>
efe8e12
to
c9e6cc2
Compare
.changeset/twenty-ads-follow.md
Outdated
"@cloudflare/vite-plugin": patch | ||
--- | ||
|
||
fix applications not being able to import assets from dependencies |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general I am keen on a little more context in changesets.
This is what will appear in the changelog and the reader will use it to determine if they should update to this version and/or what effect it will have on their project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In particular I think we should say that we now error if the user has invalid config, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes that's a good callout, I wrote this changeset when I made my initial change (which didn't actually change how we validated things) but forgot to update it, I will do that now thanks 🙂
Fixes #8664
Fixes remix-run/react-router-templates#104
This PR fixes server side code being run using our vite pluging being unable to import assets from dependencies
(e.g.
import stylesheet from "@shopify/polaris/build/esm/styles.css?url";
in react ssr code)