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
[ERROR] The entry point "./node_modules/x/y.ts" cannot be marked as external #18
Comments
Oh, that's because esrun does not bundle dependencies by default and its "what should I bundle?" strategy changed in 3.2.8. The new strategy is safer and support Typescript aliases, so I still encourage to use 3.2.8 over 3.2.7. Since 3.2.8, I delegated to The true fix would be that esbuild prevents any of the entry files (in your case, "./node_modules/x/y.ts") to be marked as externals. I created an issue on esbuild and will leave this one open while the other is not resolved. |
I just came from the esbuild issue you just posted, and was glad to see some other project using the build api of esbuild to create ts runner. Because I developed @hyrious/esbuild-dev which does exactly I used to write a simple script to find // node_modules/lib/index.js
// cjs-module-lexer DETECTS: NO EXPORTS
(function (e) {
e.a = 'a';
e['b'] = 'b';
})(exports); This is common to see in many poorly wrapped UMD libraries. Unfortunately now even Node.js 18 cannot automatically find and add names (a and b) to that module, your code will break if you write this: import { a, b } from "lib" // error: not found named export 'a', 'b' I don't want people to know this tiny dark-side of ESM-CJS interop convension in Node.js and/or in esbuild (in fact, other ts runners based on transform api are facing this problem that it requires user to know how cjs-module-lexer works, not to mension that they will be hard to support tsconfig.json without plenty of code). If we bundle the That's it, I myself is keeping my own runner simple and stupid (KISS), it should |
Hi friend Typescript runner developper :p I've decided to not bundle dependencies after giving a lot of thought to the problem. Esrun's strategy is the following:
Compiling to ESM over CJS provides the advantage of unlocking the modern ESM capabilities, like top-level await (it would not be possible with CJS). Not bundling dependencies have the following advantages:
The other strategy (bundling everything including dependencies into CJS), has got point 2. but not 1. et 3., so I've decided to go for the no-bundle strategy. It works quite well actually! |
Esbuild fixed the issue, I updated Esrun to match a newer version of Esbuild. Will work with esrun@3.2.18 or later |
After upgrading to esrun
v3.2.8
, when I use esrun, I get the following error:[ERROR] The entry point "./node_modules/x/y.ts" cannot be marked as external
When running the following command:
npx esrun ./node_modules/x/y.ts
(The TS file that I'm running only contains a
console.log
)Downgrading to esrun
v3.2.7
fixes the error.The text was updated successfully, but these errors were encountered: