-
Notifications
You must be signed in to change notification settings - Fork 3
Description
Describe the bug
To simplify the process of migrating to TypeConfiguration classes from Declarators, I created a library for housing my models. That all worked fine, and I am set up to finish the migration. Unfortunately, I ran into a speed bump. No matter how I configure my build and test configurations, I run into import CJS issues with this library (as well as entity-store and json-api-entity-provider). Thing is... I am using ESM, not CJS.
I took a deeper look into this library's package.json and dist files, and I think I see the issue.
- The package.json uses the legacy configuration, pointing to
mainmoduleandtypes, instead ofexports` - The
es5andes2015do not point to subdirectories in a way compatible with strict ESM environments (such as webpack or vitest)
I'd like to pick your brain on solving this. I could easily add a build tool such as unbuild to compile a .cjs and a .mjs file for compatibility. Since your library doesn't output a .cjs or .mjs file, I think this wouldn't break compatibility. That said, I really don't have experience with UMD vs. ES5 vs. ES2015 vs. ESM.
Let me know what your thoughts are, if you'd like, I can easily create a draft PR.
- in the meantime, I may setup a project on UMD, ES5 and ES2015 to verify compatibility
To Reproduce
Steps to reproduce the behavior:
- Build this library
- Check to see if index.js points to subfolders such as
functionsby syntax./functions/index
OR
- Create a library and define some models
- Add the library to an app, and check that tools such as webpack or vitest run
The log I get, when I brute force ESM:
data-api\node_modules\@dipscope\entity-store\dist\es2015\command-builders' is not supported resolving ES modules imported from data-api\node_modules\@dipscope\entity-store\dist\es2015\index.js
Expected behavior
The ideal solution, would be the ability to consume this library in another library, and import that library in an app.
- ESM would be nice, as that allows for named imports.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: Windows
- Browser: ESM based node (vitest)
Additional Context
Again, I don't mind adding in build tools and configuring them. I just want to run the idea by you first, and see what you'd like the outcome of the changes to look like. (For example, do you want to make sure that ES5/ES2015/UMD are output, or is just CJS/ESM fine, or all of the above)