Skip to content

TypeError while launching Wrangler without file extension, ie "./index" #78

@jgentes

Description

@jgentes

While using wrangler dev ./index I get

TypeError: Cannot read properties of undefined (reading '0')
    at null.build (/home/jgentes/workers/wrangler2/packages/wrangler/src/dev.tsx:411:15)

This is caused due to the entry value being verbatim what was used as a command line argument, ie. ./index, whereas the entryPoint value in result.metafile.outputs has the extension added to the file, ie ./index.js.

I'm going to submit a PR that uses what esBuild recognizes as the input value in result.metafile.inputs instead of the entry value:

const chunks = Object.entries(result.metafile.outputs).find(
        ([_path, { entryPoint }]) =>
          entryPoint === Object.keys(result.metafile.inputs)[0]
      ) // assumedly only one entry point

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions