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

Presence of module and main fields in package.json #359

Closed
BlueGhostAlt opened this issue Sep 1, 2020 · 1 comment
Closed

Presence of module and main fields in package.json #359

BlueGhostAlt opened this issue Sep 1, 2020 · 1 comment

Comments

@BlueGhostAlt
Copy link

I am trying to bundle my TypeScript files, specifically local sandbox files for trying out my package before publishing it, and I am trying to transpile and bundle my TypeScript files with the following command:

yarn esbuild --outdir=sandbox/dist --target=esnext --tsconfig=tsconfig.sandbox.json --platform=node --bundle sandbox/index.ts

The expected output would be to find my bundled index.js file in sandbox/dist, but instead of that, I get an error:

error: Cannot read directory "dist/esm": The system cannot find the path specified.
package.json:9:14: error: Cannot read directory "dist/esm/index.js": The system cannot find the path specified.
    "module": "dist/esm/index.js",
              ~~~~~~~~~~~~~~~~~~~
2 errors
Done in 0.26s.

My package.json entrypoints are as follows:

{
    "main": "dist/cjs/index.js",
    "module": "dist/esm/index.js",
    "typings": "dist/index.d.ts"
}

Things that solve the issue:

  1. Creating a dist/esm directory
  2. Removing both the main and the module entrypoints(removing just module will lead to esbuild erroring out as it cannot find "dist/cjs/index.js")

Is there any way to solve this without having an otherwise useless directory(I'm not outputting anything there) or without having to develop with my entrypoints missing, adding them back before comitting every time?

I am using esbuild 0.6.28, running on a Windows 10 machine with Node v14.8.0.

@BlueGhostAlt BlueGhostAlt changed the title Presence of module and main field in package.json Presence of module and main fields in package.json Sep 1, 2020
@evanw
Copy link
Owner

evanw commented Sep 2, 2020

Thanks for reporting this. It looks like this is a Windows-only issue, and is a regression from the previous release. I’ll fix this in the next release.

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

No branches or pull requests

2 participants