-
Notifications
You must be signed in to change notification settings - Fork 735
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
Custom Miniflare CLI #633
Custom Miniflare CLI #633
Conversation
🦋 Changeset detectedLatest commit: 0d3b5ad 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 |
A wrangler prerelease is available for testing. You can install this latest build in your project with: npm install --save-dev https://prerelease-registry.developers.workers.dev/runs/2017790481/npm-package-wrangler-633 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/633/npm-package-wrangler-633 Or you can use npx https://prerelease-registry.developers.workers.dev/runs/2017790481/npm-package-wrangler-633 dev path/to/script.js |
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.
Nice! 🎉 This looks really good! Added a few comments. 🙂
2ba2587
to
a1bdb72
Compare
packages/wrangler/src/dev/local.tsx
Outdated
) | ||
), | ||
durableObjectsPersist: enableLocalPersistence, | ||
cachePersist: !enableLocalPersistence, |
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.
shouldn't this be just enableLocalPersistence
?
cachePersist: !enableLocalPersistence, | |
cachePersist: enableLocalPersistence, |
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.
And yes again! I suspect this was a late night change 😵
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.
Let's try to land this soon-ish so we can try it out. I'll give a stamp to unblock, but don't forget the package.json/cachePersist fixes
This allows us to tightly control the options that are passed to Miniflare. The current CLI is setup to be more compatible with how Wrangler 1 works, which is not optimal for Wrangler 2.
… and logUnhandledRejections: true (to catch unhandled rejections instead of crashing) here
Previously, asset file paths were computed relative to the current working directory, even if we had used `-c` to run Wrangler on a project in a different directory to the current one. Now, assets file paths are computed relative to the "project root", which is either the directory containing the wrangler.toml or the current working directory if there is no config specified.
4c245e7
to
3fe320a
Compare
added a join to the helper that is passed into Dev for asset paths.
d2bf09b
to
0d3b5ad
Compare
In #633, we missed passing a cwd to the process that runs the miniflare cli. This broke how miniflare resolves modules, and led back to the dreaded "path should be a `path.relative()`d string" error. The fix is to simply pass the cwd to the `spawn` call.
In #633, we missed passing a cwd to the process that runs the miniflare cli. This broke how miniflare resolves modules, and led back to the dreaded "path should be a `path.relative()`d string" error. The fix is to simply pass the cwd to the `spawn` call. Test plan: ``` cd packages/wrangler npm run build cd ../workers-chat-demo npx wrangler dev --local ```
In #633, we missed passing a cwd to the process that runs the miniflare cli. This broke how miniflare resolves modules, and led back to the dreaded "path should be a `path.relative()`d string" error. The fix is to simply pass the cwd to the `spawn` call. Test plan: ``` cd packages/wrangler npm run build cd ../workers-chat-demo npx wrangler dev --local ```
Prevents the following being included in the npm tarball: - `src`: we may want to ship this if we shipped source maps, so users could click on internal lines in stack traces, but we don't ship source maps to npm, so these aren't needed. - `miniflare-config-stubs`: these aren't used as of #633 (https://github.com/cloudflare/workers-sdk/pull/633/files#diff-dd2c9d6fc577a3da1b7cf0b6b4a0705a1c71eb5d99c372d5bdda99476362f975L97-L102) - `vendor`: this directory doesn't actually exist in the `wrangler` package directory, there is a root `vendor` directory, but files from that are copied to `wrangler-dist` during build Closes #3013
Prevents the following being included in the npm tarball: - `src`: we may want to ship this if we shipped source maps, so users could click on internal lines in stack traces, but we don't ship source maps to npm, so these aren't needed. - `miniflare-config-stubs`: these aren't used as of #633 (https://github.com/cloudflare/workers-sdk/pull/633/files#diff-dd2c9d6fc577a3da1b7cf0b6b4a0705a1c71eb5d99c372d5bdda99476362f975L97-L102) - `vendor`: this directory doesn't actually exist in the `wrangler` package directory, there is a root `vendor` directory, but files from that are copied to `wrangler-dist` during build Closes #3013
Prevents the following being included in the npm tarball: - `src`: we may want to ship this if we shipped source maps, so users could click on internal lines in stack traces, but we don't ship source maps to npm, so these aren't needed. - `miniflare-config-stubs`: these aren't used as of #633 (https://github.com/cloudflare/workers-sdk/pull/633/files#diff-dd2c9d6fc577a3da1b7cf0b6b4a0705a1c71eb5d99c372d5bdda99476362f975L97-L102) - `vendor`: this directory doesn't actually exist in the `wrangler` package directory, there is a root `vendor` directory, but files from that are copied to `wrangler-dist` during build Closes #3013
Prevents the following being included in the npm tarball: - `src`: we may want to ship this if we shipped source maps, so users could click on internal lines in stack traces, but we don't ship source maps to npm, so these aren't needed. - `miniflare-config-stubs`: these aren't used as of #633 (https://github.com/cloudflare/workers-sdk/pull/633/files#diff-dd2c9d6fc577a3da1b7cf0b6b4a0705a1c71eb5d99c372d5bdda99476362f975L97-L102) - `vendor`: this directory doesn't actually exist in the `wrangler` package directory, there is a root `vendor` directory, but files from that are copied to `wrangler-dist` during build Closes #3013
Previously, Miniflare CLI was being ran for local through a child process which made passing options into it complicated for more complex inputs.
Solution: Create a custom CLI wrapper around Miniflare API
This allows us to tightly control the options that are passed to Miniflare.
Bugfix: Likely pathing to the current working directory only worked if ran in the directory with a Worker, the base directory is now an absolute path to the directory with a
wrangler.toml
The current CLI is setup to be more compatible with how Wrangler 1 works, which is not optimal for Wrangler 2.