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

Duplicate output files: dist/main.js and workers-site/worker/script.js #1046

Closed
computator opened this issue Feb 12, 2020 · 6 comments
Closed
Labels
sites webpack Issues that involve the `webpack` bundler

Comments

@computator
Copy link

🐛 Bug Report

I recently created a workers site, and was looking through the generated files to decide what was temporary and what to commit. I noticed that there were two identical files:

  • dist/main.js
  • workers-site/worker/script.js

I spent some time trying to figure out why both existed, and which was the original vs duplicate. From what I can tell, dist/main.js is the webpack output, and the other file is a duplicate of it. It seems that at one point, both files existed because some other code was prepended to the webpack output before it was written to worker/script.js, but this appears to no longer be the case. It seems to have been removed in e7416ff. Seeing as the two files are redundant and slightly confusing, maybe webpack should be configured to output directly to worker/script.js or something instead. The current process seems to have caused #681 as well.

Environment

  • operating system: Ubuntu 18.04
  • output of rustc -V: not installed
  • output of node -v: v8.10.0
  • output of wrangler -V: wrangler 1.7.0 (Unrelated: it seems maybe wrangler inserts a space before the version string by accident?)
@xtuc
Copy link
Member

xtuc commented Feb 13, 2020

I can confirm that dist/main.js is the webpack and worker/script.js in the worker. We could technically remove/hide the webpack output by proccessing it in wrangler's memory.

@stale
Copy link

stale bot commented Jul 12, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@TooYoungTooSimp
Copy link

Meet the same problem. Hope it can be fix soon.

@lfender6445
Copy link

I can confirm that dist/main.js is the webpack and worker/script.js in the worker. We could technically remove/hide the webpack output by proccessing it in wrangler's memory.

did you mean to say that worker/script.js is not an artifact of webpack?

i am wondering in the meantime is it possible to configure webpack config so that output of both files go to single directory, eg dist

@da99
Copy link

da99 commented Nov 28, 2020

i am wondering in the meantime is it possible to configure webpack config so that output of both files go to single directory, eg dist

For the current version of wrangler (v1.12.2):

The default output file seems to have changed to dist/worker.js.
The output file worker/script.js doesn't seem able to be customized at the moment because it is hard-coded in Rust: https://github.com/cloudflare/wrangler/blob/v1.12.2/src/wranglerjs/bundle.rs (lines 13 and 63).

I guess it would be alright to customize the default dist output dir to worker to keep all files in one place:

// file: webpack.config.js
const path = require("path");
module.exports = {
  target: "webworker",
  output: {
    path: path.resolve(__dirname, 'worker/')
  }
}

However, I could never figure out why the 2 files are created in 2 different places but with the same content: worker/script.js and dist/worker.js

@Electroid Electroid added webpack Issues that involve the `webpack` bundler and removed user report labels Feb 22, 2021
@xortive xortive added the sites label Feb 25, 2021
@xortive
Copy link
Contributor

xortive commented Apr 9, 2021

closed by #1833 (since you can use custom builds to avoid this)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
sites webpack Issues that involve the `webpack` bundler
Projects
None yet
Development

No branches or pull requests

9 participants