Skip to content
This repository has been archived by the owner on Aug 3, 2023. It is now read-only.

allow for wrangler publish without npm install #778

Closed
iameli opened this issue Oct 11, 2019 · 6 comments
Closed

allow for wrangler publish without npm install #778

iameli opened this issue Oct 11, 2019 · 6 comments
Labels

Comments

@iameli
Copy link

iameli commented Oct 11, 2019

💡 Feature request

Overview and problem statement

Livepeer has a Yarn monorepo and running npm install in it kind of mucks things up. I've already got a completely compiled worker.js suitable for uploading as a Cloudflare worker, as well as a static HTML Next.js site that I'd like uploaded to Workers Sites. I don't need any of the npm automation provided by wranglerjs, but it'd still be nice to be able to use wrangler publish.

Here's the wrangler.toml I'm using.

Basic example

Seems like it'd be a configuration flag in wrangler.toml?

do_install = false
@gusvargas
Copy link
Contributor

I think that this is sort of related to #428 (comment)

@iameli
Copy link
Author

iameli commented Oct 11, 2019

Yeah, I hear that — related to this would be supporting yarn in addition to npm. I understand how the automatic npm install is useful for folks that are new to JavaScript bundling and whatnot, but there's just no way you could possibly predict all the myriad of ways that complex projects handle dependency management and building. Running npm install totally breaks Livepeer's JavaScript repo.

FWIW I worked around this by committing an empty package.json adjacent to the worker.js file, resulting in a no-op npm install upon wrangler publish. Works fine now.

@gusvargas
Copy link
Contributor

The more I've thought about this the less I think wrangler should be concerned with package management at all. build seems like it should just run webpack or whatever to produce an artifact that will later be consumed by preview or publish, i.e., running build would be a necessary precursor to running preview or publish. Similar to cargo, wrangler build could produce directories like target/preview and target/release. The build will fail if dependencies haven't been installed correctly.

Decoupling those steps and allowing the "target" directory to be configurable (like wrangler preview --target ./foo/dist-worker) seems like it would resolve your issue without requiring hacks.

@xtuc
Copy link
Member

xtuc commented Oct 15, 2019

@gusvargas In my opinion, that's the ideal case. However, you are missing context and implementation details here.

We did focus on UX by installing the user's dependecies (if needed). wranglerjs is an internal tool that needs its dependecies. It's a tradeoff between running it all the time to be correct or running it only once and assume it will be correct. See #765

@ashleymichal
Copy link
Contributor

Closing in favor of #820, please track work there.

@samkelleher
Copy link

samkelleher commented Feb 26, 2020

I have the same issue where wrangler publish keeps breaking because of npm install issues which have nothing to do with my yarn projects build or deployment.

I don't believe wrangler should really have anything to do with builds, but I get it's there to give a good out the box experience.

I did in the end write a example custom script I'll share for anyone interested that uploads the built worker and a KV asset via the API, bypassing wrangler.

https://github.com/samkelleher/wasm-embed/blob/master/src/deploy.mjs

If your use case is just for publishing, this might be of use.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

6 participants