Skip to content

Webpack config does not coincide with package.json "main" or README #12

@theruggerdev

Description

@theruggerdev

The webpack config defines the build out put as follows:

output: {
    filename: `worker.${mode}.js`,
    path: path.join(__dirname, 'dist'),
  },

but the package.json defines the main entrypoint as index.js, which will never exist, and will be used by wrangler preview to serve a local demo, and obviously anything else that relies on the main property of package.json to run the code.

Resolution

  1. The main property of package.json should be updated to match the file output in webpack.config
  2. The output file of webpack.config should not be dynamic and always output to whatever the main property of package.json is

I suggest (based on typical best practices):
// webpack.config.js

output: {
    filename: `index.js`,
    path: path.join(__dirname, 'dist'),
  },

// package.json

"main": "dist/index.js"

There is no need to build to different filenames for different modes, a developer or even a CI/CD runner should know whether it is running in a particular mode which may affect the structure and content of the built files, but the names should be the same so any issues for the same file in different environments can be compared without headaches or the need to look into build configurations for different modes.

Finally, the readme has the link to the index function in src labelled with .js extension, when it is a .ts file. The readme should also have content explaining the dev (I have more to say about the dev script, but beyond the scope of this issue) and build scripts, and maybe a one-liner to mention using wrangler preview.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions