Skip to content
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 type: module and use .cjs/.mjs extension #119

Open
unional opened this issue Aug 5, 2024 · 2 comments · May be fixed by #122
Open

add type: module and use .cjs/.mjs extension #119

unional opened this issue Aug 5, 2024 · 2 comments · May be fixed by #122

Comments

@unional
Copy link

unional commented Aug 5, 2024

Currently when consuming this project with moduleResolution: Node16/NodeNext fail with the following errors:

.../node_modules/micro-memoize/src/Cache.ts(4,10): error TS1286: ESM syntax is not allowed in a CommonJS module when 'verbatimModuleSyntax' is enabled.

Add type: module and use .cjs/.mjs extension would fix it.

i.e.:

  • add type: module
  • dist/micro-memoize.cjs.js -> dist/micro-memoize.cjs
  • dist/micro-memoize.mjs.js -> dist/micro-memoize.mjs
@planttheidea
Copy link
Owner

Unfortunately, this by itself causes a breaking change with how this package is both built and consumed, and I try to adhere to semver as much as possible. I'm working on a v5 that can easily include this change, so I can include it there.

That said, I can piggyback on a simple hack I do for .mjs files that can also be done for cjs. I mention this in the import documentation, but there is a separate micro-memoize/mjs import that is available. I can do the same for CJS, which is not ideal but would likely give you what you need to avoid this error (so long as you use the micro-memoize/cjs) location. If you're willing, I'll spin up a beta of that change that you can test out locally.

@planttheidea planttheidea linked a pull request Jan 5, 2025 that will close this issue
@planttheidea
Copy link
Owner

I've published 4.2.0-beta.0 with the new micro-memoize/cjs access point, which you should be able to install with just npm install micro-memoize@next. Let me know if this is able to give you what you need for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants