Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related issue: #1050
Summary of the changes
type="module"
key from the package'spackage.json
files👆 This is the primary change that resolved the issue. The following changes were downstream of this change. Once this change was made the import worked again as expected:
lib/*.cjs
file tolib/*.js
.👆 The use of the
.cjs
extension is no longer required because the module type is no longer explicitly defined. Consumer's bundlers will be able to resolve both the es and cjs modules appropriately with standard.js
extensions now.rollup.config.js
files torollup.config.mjs
👆 Because the module type is longer explicitly defined, CommonJS is the default node environment for each package. This means that we need a
.mjs
to use es modules in all of the local node scripts.c8 node --test-reporter=spec --loader
part of the core test script🚨 I was unable to get the existing tests to work with the current configuration/setup and the aforementioned changes. I found the the
tsx
command worked fine on its own. However, there was some issue loadingtsx
through node that was preventing it from resolving the modules properly. I looked into it and it turns out that--loader
option is actually experimental and may be removed. In fact, there is an existing warning about it in the console when the tests are run:Obviously, I do not expect you to accept these updates without code coverage of your tests. However, I think this might be a good opportunity to resolve both issues (removal of
--loader
andtype="module"
). I am confident that an alternative methods or tool would work. FWIW, I have had great success with Jest and Vitest. If it would be helpful, I'd even be willing to do some of the footwork.