estrella
estrella copied to clipboard
estrella doesn't seem to be working within ESM context
As more and more dependencies are updating to ESM, I've figured it's time to bite the bullet and make my project ESM-ready as well.
But adding "type": "module"
to my project's package.json leads to these two issues when running node build.js
:
-
import {build, cliopts} from "estrella"; ^^^^^ SyntaxError: Named export 'build' not found. The requested module 'estrella' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using: import pkg from 'estrella'; const {build, cliopts} = pkg;
the proposed workaround works though.
-
TypeError: Cannot read properties of undefined (reading 'filename')
this is due to this code:https://github.com/rsms/estrella/blob/e5b985bd3292ddaa87022b97062be2f18b15b182/src/util.js#L27
process.mainModule
does not seem to exist in ESM.
I'm experiencing the second issue, too.
The solution to 1. is listed in the error message - if I destructure the estrella import I can repro your issue, but it works fine for me like:
// fails:
// import { build } from "estrella";
// works:
import estrella from 'estrella'
const { build } = estrella
TypeError: Cannot read properties of undefined (reading 'filename')
I wonder if this is due to "Breaking API change to WatchCallback" in https://github.com/rsms/estrella/releases/tag/v1.4.0?
Downgrading estrella to 1.3.x resolves my issue 👍
Context / repro: I'm playing with https://github.com/sunderjs/sunder-worker-template (see build.js, and I recklessly upgraded all deps 😆
I'm experiencing the second issue (TypeError: Cannot read properties of undefined (reading 'filename')
) as well on a project that worked fine with v1.3.x.
I need 1.4.x because I'm building a browser JS bundle and without the sourcesContent
option, my sourcemaps are broken.
(@ptim ironically, I was using the same template for my use case)
I proposed a fix via #53. it works locally for me and all tests pass.
This issue is still relevant.
Any chance to accept the PR?