-
Notifications
You must be signed in to change notification settings - Fork 769
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
[wrangler] Add experimental assets config and flag #6312
Conversation
🦋 Changeset detectedLatest commit: 443fe96 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
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.devprod.cloudflare.dev/workers-sdk/runs/10093694977/npm-package-wrangler-6312 You can reference the automatically updated head of this PR with: npm install --save-dev https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/prs/6312/npm-package-wrangler-6312 Or you can use npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10093694977/npm-package-wrangler-6312 dev path/to/script.js Additional artifacts:npx https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10093694977/npm-package-create-cloudflare-6312 --no-auto-update npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10093694977/npm-package-cloudflare-kv-asset-handler-6312 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10093694977/npm-package-miniflare-6312 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10093694977/npm-package-cloudflare-pages-shared-6312 npm install https://prerelease-registry.devprod.cloudflare.dev/workers-sdk/runs/10093694977/npm-package-cloudflare-vitest-pool-workers-6312 Note that these links will no longer work once the GitHub Actions artifact expires.
Please ensure constraints are pinned, and |
bff744e
to
58b27ed
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.
Approving Emily's changes on behalf of Workers + Assets team. We should get another review though, since I added some small fixes myself
58b27ed
to
c200ca7
Compare
7b204ca
to
a11bea0
Compare
throw new UserError( | ||
`The directory specified by the "--experimental-assets" command line argument does not exist:\n` + | ||
`${path.resolve(experimentalAssetsBasePath, args.experimentalAssets)}` | ||
const experimentalAssets = args.experimentalAssets |
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.
this is merging args and config into one ExperimentalAssets
shape for convenience. I also expect this will come in handy once we start to implement the dev/deploy behaviour, Same is done in dev
@@ -891,3 +886,8 @@ export interface UserLimits { | |||
/** Maximum allowed CPU time for a Worker's invocation in milliseconds */ | |||
cpu_ms: number; | |||
} | |||
|
|||
export type ExperimentalAssets = { |
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.
as per our sync call today, moving away from array support, as this is not something for this iteration
packages/wrangler/src/dev.tsx
Outdated
const experimentalAssets = args.experimentalAssets | ||
? { directory: args.experimentalAssets } | ||
: config.experimental_assets; | ||
if (experimentalAssets) { | ||
const experimentalAssetsBasePath = getExperimentalAssetsBasePath( | ||
config, | ||
args.experimentalAssets | ||
); | ||
const resolvedExperimentalAssetsPath = path.resolve( | ||
experimentalAssetsBasePath, | ||
experimentalAssets.directory | ||
); | ||
|
||
if (!existsSync(resolvedExperimentalAssetsPath)) { | ||
const sourceOfTruthMessage = args.experimentalAssets | ||
? '"--experimental-assets" command line argument' | ||
: '"experimental_assets.directory" field in your configuration file'; | ||
|
||
throw new UserError( | ||
`The directory specified by the "--experimental-assets" command line argument does not exist:\n` + | ||
`${path.resolve(process.cwd(), args.experimentalAssets)}` | ||
`The directory specified by the ${sourceOfTruthMessage} does not exist:\n` + | ||
`${resolvedExperimentalAssetsPath}` |
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.
I feel a bit bad that this is a duplicate of the same code in the deploy command...
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.
yeah, I'm aware of the code duplication. I can abstract the user error logic into a separate fn if that helps. I don't have strong opinions either way, other than that we should not abstract all of this code block away, as that might become unreadable. Plus we might see some differences as we move further into the implementation.
This commit adds a new experimental CLI flag (`--experimental-assets`) and configuration key (`experimental_assets`) for the new Workers + Assets work. The new flag and configuration key are for the time being "inactive", in that no behaviour is attached to them yet. This will follow up in future work.
8b6c7ab
to
443fe96
Compare
What this PR solves / how to test
Add an experimental asset config key and flag.
Doesn't really do anything yet but should have appropriate validation.
See WC-2389
Author has addressed the following