Comments (3)
Hello @bashmish, thank you for the issue and sorry for the delay.
I'm not sure if I understood the problem correctly. Indeed, the typings of @parcel/source-map
suggest a default export of SourceMap
, but this is not true on the implementation side.
As you can see here: link, the module exports the class like this:
exports.default = NodeSourceMap;
But it should be:
exports = NodeSourceMap;
in order for the class to be imported as the default member.
As you mentioned, we prefer Node with ESM, so I'm wondering if there's some scenario where the import is modified by a transpiler. Could you provide a reproduction case for us to investigate?
Nevertheless, we are certainly available to handle the scenario as soon as we understand it :)
from rna.
@edoardocavazza I ran into similar issues just yesterday, so good timing, since it gave me more knowledge to answer :)
Indeed there is a transpiler somewhere which dynamically patches ESM modules to be consumed by CommonJS modules. I don't know exactly how to solve it yet, I might still require a fix on your side, but for the time being I'll close this issue. Thank you so far!
from rna.
I'd like to reopen this.
Did a bit more digging into this problem and found out it's the well-known issue with default exports CJS/ESM interop which can't be solved by tools automatically in all cases.
There is a good explainer here https://esbuild.github.io/content-types/#default-interop
In my case I end up having The Babel interpretation
somewhere in my toolchain. It's hard to pin-point where exactly as I have multiple layers of tools, which I don't always control, but I tried to play with configs after learning the heuristics that esbuild uses when choosing either The Babel interpretation
or The Node interpretation
, yet I couldn't make it work with current estransform
published code.
In your case the The Node interpretation
takes place and that requires you use this code:
import sourceMapDefault from '@parcel/source-map';
const { default: SourceMapNode } = sourceMapDefault;
This is a good workaround for apps, but for libs I think there is a better one which can solve it both for you and me. On top of that the TypeScript required you to copy over some types into packages/estransform/modules.d.ts
from @parcel/source-map
which can also be improved.
This problem and workarounds for it are also discussed in this esbuild issue.
from rna.
Related Issues (20)
- [esbuild-plugin-alias] Align with esbuild builtin alias management HOT 1
- esbuild-plugin-html does not use the original directory of the source file HOT 6
- esbuild-plugin-meta-url only transforms node_modules? HOT 1
- document how to interop normal esbuild plugin with esbuild-rna plugin HOT 2
- Unable to specify an output directory with esbuild-plugin-meta-url HOT 3
- Feature Request: Single Page Application support for the HTML plugin. HOT 1
- feat: [esbuild-plugin-html] Support esbuild `publicPath` HOT 1
- SyntaxError: Identifier '__filename' has already been declared HOT 3
- Weird behavior when not using `hash`
- Minimize html
- Error with `require-resolve` HOT 2
- esbuild-plugin-html only watches the HTML file HOT 7
- esbuild-plugin-meta-url + quickjs-emscripten aborts
- Replace `punycode` module due to deprecation HOT 4
- How to get metadata when building HTML files? HOT 1
- Insert <link> directly, without an intermediate <script> HOT 10
- import.meta.url is undefined for CommonJS output, causing TypeError [ERR_INVALID_ARG_VALUE]
- Plugin incompatibility
- empty style tag in html file results in "error: Could not resolve" path to "1.css"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rna.