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

Avoid uploading the functions/ directory as part of wrangler pages publish #2103

Merged
merged 1 commit into from
Nov 2, 2022

Conversation

GregBrimble
Copy link
Member

Don't upload functions/ directory as part of wrangler pages publish

If the root directory of a project was the same as the build output directory, we were previously uploading the functions/ directory as static assets. This PR now ensures that the functions/ files are only used to create Pages Functions and are no longer uploaded as static assets.

Additionally, we also now do upload _worker.js, _headers, _redirects and _routes.json if they aren't immediate children of the build output directory. Previously, we'd ignore all files with this name regardless of location. For example, if you have a public/blog/how-to-use-pages/_headers file (where public is your build output directory), we will now upload the _headers file as a static asset.

@changeset-bot
Copy link

changeset-bot bot commented Oct 31, 2022

🦋 Changeset detected

Latest commit: ccafb81

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

This PR includes changesets to release 1 package
Name Type
wrangler 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

@github-actions
Copy link
Contributor

github-actions bot commented Oct 31, 2022

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/3376938856/npm-package-wrangler-2103

You can reference the automatically updated head of this PR with:

npm install --save-dev https://prerelease-registry.developers.workers.dev/prs/2103/npm-package-wrangler-2103

Or you can use npx with this latest build directly:

npx https://prerelease-registry.developers.workers.dev/runs/3376938856/npm-package-wrangler-2103 dev path/to/script.js
Additional artifacts:
npm install https://prerelease-registry.developers.workers.dev/runs/3376938856/npm-package-cloudflare-pages-shared-2103

Copy link
Member

@WalshyDev WalshyDev left a comment

Choose a reason for hiding this comment

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

Compiled Worker successfully.
IGNORING functions
IGNORING node_modules

Nice. This looks good to me, looks like a test needs updating

Ty for fixing this!

@codecov
Copy link

codecov bot commented Oct 31, 2022

Codecov Report

Merging #2103 (ccafb81) into main (2a81cae) will increase coverage by 0.09%.
The diff coverage is 93.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2103      +/-   ##
==========================================
+ Coverage   73.11%   73.20%   +0.09%     
==========================================
  Files         127      128       +1     
  Lines        8610     8641      +31     
  Branches     2264     2266       +2     
==========================================
+ Hits         6295     6326      +31     
  Misses       2315     2315              
Impacted Files Coverage Δ
packages/wrangler/src/is-interactive.ts 85.71% <50.00%> (-14.29%) ⬇️
packages/wrangler/src/pages/constants.ts 100.00% <100.00%> (ø)
packages/wrangler/src/pages/upload.tsx 85.71% <100.00%> (+0.57%) ⬆️
...ckages/wrangler/src/__tests__/helpers/msw/index.ts 100.00% <0.00%> (ø)
.../src/__tests__/helpers/msw/handlers/deployments.ts 100.00% <0.00%> (ø)
packages/wrangler/src/index.tsx 83.12% <0.00%> (+1.18%) ⬆️
...ackages/wrangler/src/__tests__/helpers/mock-bin.ts 100.00% <0.00%> (+5.26%) ⬆️

@GregBrimble
Copy link
Member Author

Didn't mean to leave in that console.log() — I've removed it now.

@WalshyDev
Copy link
Member

I think it might be nice to have a log for it tbh

@GregBrimble
Copy link
Member Author

Maybe we can add it back later with a WRANGLER_LOG_LEVEL or whatever that's called now. Having it by default is quite noisy imo.

packages/wrangler/src/pages/upload.tsx Outdated Show resolved Hide resolved
packages/wrangler/src/pages/upload.tsx Outdated Show resolved Hide resolved
@CarmenPopoviciu
Copy link
Contributor

CarmenPopoviciu commented Nov 1, 2022

TIL. I had no idea this is happening. Can you please add some tests for the scope of this PR? I'm thinking a unit test to verify that output Walshy mentioned (or smth along those lines)

Compiled Worker successfully.
IGNORING functions
IGNORING node_modules

and maybe a fixture (could also update an existing fixture) to test that _headers, _redirects, etc do get uploaded if not direct children of build output dir. WDYT? Will leave it up to you , just as long as we have something that tests the correct behaviour ¯_(ツ)_/¯

other than that 💯

@GregBrimble GregBrimble merged commit f1fd62a into main Nov 2, 2022
@GregBrimble GregBrimble deleted the avoid-uploading-functions-dir branch November 2, 2022 11:26
@github-actions github-actions bot mentioned this pull request Nov 2, 2022
@isaac-mcfadyen
Copy link
Contributor

isaac-mcfadyen commented Nov 2, 2022

I'd warn against logging it or reword the message or something. If I'm a new user and I don't know what it means, it looks like wrangler just ignored all of my Functions (even for regular Function things).

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.

4 participants