-
-
Notifications
You must be signed in to change notification settings - Fork 47
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
Add .cjs as list of potential JS files #75
Conversation
I think this makes sense. However, in #68, we identified that falling back to node's loader will load the cjs file anyway. Can you explain a little more how plopjs loads things so I can understand why falling back doesn't work? |
Whoops! I missed #68, my bad. For context, I'm using an https://github.com/plopjs/node-plop/blob/master/src/node-plop.js#L198 Where https://github.com/plopjs/plop/blob/master/src/plop.js#L18-L24 https://github.com/plopjs/plop/blob/master/src/plop.js#L56-L59 However, when I was working on CLI E2E tests, I ran into issues with CJS files loading properly https://github.com/plopjs/plop/blob/master/tests/esm.spec.js#L30-L39 This test currently passes, but if I remove the https://github.com/plopjs/plop/blob/master/src/plop.js#L22 This test then fails |
Well, I'm convinced! I'm happy to have a real-world use case to prove that it is needed. I'll get this merged and released today. |
@crutchcorn I'm trying to figure out how to write a test for this right now. |
@phated gotcha! I can see about adding them if that'd be helpful Far from any rush though, we've already published v3 and it's working rather well with the extension changes :) |
That'd be a ton of help! I've not done much with |
@crutchcorn do you still have some availability to get tests written for this? |
I took a quick stab and I'll admit that I don't understand the testing methodologies at play well enough to move forward. Admittedly, the tests should look similar to
|
@crutchcorn the issue, if I remember, is that our test harness is running under commonjs, so we can never test the cjs extension. I think that you'll need to exec some script in a different directory that enables the module context |
@crutchcorn I rebased this and added some tests. Can you sanity check them for me to make sure this is what you expect? |
Tests are passing. Just waiting on @crutchcorn's feedback 😄 |
Tests LGTM! |
Thanks for getting this started and checking out the tests! Sorry it has taken so long to get released (it'll ship with the 3.0 changes) |
When using
type="module"
, there's still the ability to usecommonjs
stylerequire
andmodule.exports
in.cjs
files (as opposed to.js
files).This PR adds it as a candidate for files that can be handled using Liftoff
I've tested this within our close-to-release
plopjs@3
release, which will support ESM