Closed darvids0n closed 1 year ago
I am trying to use node-plop on a node js project, but unfortunately get the same error while trying to import node-plop.
This is strange, as Plop 3 is an ESM package and prefers ESM packages. Under-the-hood, we're using import
to load ESM files.
Which version of plop
/node-plop
are you using and can you provide a minimal repro?
The version of node-plop
pinned in @turbo/gen
is the one I'm using - currently 0.26.3
.
Here's a stackblitz of the issue.
That'd be why. node-plop introduced ESM in 0.30, you'll have to ask downstream to upgrade their instance of the lib.
Happy to help them upgrade the package if they reach out with any challenges or questions :)
As this is an issue downstream, I'll close this issue
Hi! Thanks for writing Plop, it's been super helpful for automating developer processes at my workplace.
Until recently I'd been using node-plop on projects which were treated as interop/CommonJS (no type=module in package.json), though the implementation itself is still ESM. However, due to my build config being ESM and getting linting issues I have started specifying the
type
field.Specifying
type: "module"
causes plop to fail to load any configs, asnode-plop
has been transpiled to cjs in the distribution, which turns theawait import
of the plopfile into arequire
only valid for CJS files.Has there been any decision made around ESM, eg bundling an ESM distribution alongside CJS? It would be good to have it.
Here's a representative stack trace (via Turborepo):