Can't use with esbuild
See original GitHub issueesbuild produces the following error
[error] ✘ [ERROR] Could not resolve "@formkit/auto-animate"
[error] ../main.js:2:51:
[error] 2 │ ...040formkit$002fauto$002danimate = require("@formkit/auto-animate");
[error] ╵ ~~~~~~~~~~~~~~~~~~~~~~~
[error] The path "." is not currently exported by package "@formkit/auto-animate":
[error] ../../../../../node_modules/@formkit/auto-animate/package.json:18:13:
[error] 18 │ "exports": {
[error] ╵ ^
[error] None of the conditions provided ("import") match any of the currently active conditions ("browser", "default", "require"):
[error] ../../../../../node_modules/@formkit/auto-animate/package.json:27:9:
[error] 27 │ ".": {
[error] ╵ ^
[error] Consider using an "import" statement to import this file, which will work because the "import" condition is supported by this package:
[error] ../main.js:2:51:
[error] 2 │ ...040formkit$002fauto$002danimate = require("@formkit/auto-animate");
[error] ╵ ~~~~~~~~~~~~~~~~~~~~~~~
[error] You can mark the path "@formkit/auto-animate" as external to exclude it from the bundle, which will remove this error. You can also surround this "require" call with a try/catch block to handle this failure at run-time instead of bundle-time.
I guess we need to add default
property to package.json
:
"exports": {
".": {
"import": "./index.mjs",
"default": "..."
}
}
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:12 (4 by maintainers)
Top Results From Across the Web
Getting Started - ESBuild
If you would like to use JSX syntax in .js files instead, you can tell esbuild to ... An additional drawback is that...
Read more >bug? cant use NODE_OPTIONS with esbuild? #2051 - GitHub
is it possible we can use NODE_PATH environment variable instead of the shell script for esbuilds bin file? see NODE_PATH option in nodejs ......
Read more >How to fix problems with esbuild in Yarn - DEV Community
This plugin lets you use Yarn with esbuild. ... But with Yarn 2 PNP, I cannot run node esbuild.config.js in my project because...
Read more >AWS SAM - Esbuild Failed: cannot find esbuild - Stack Overflow
install esbuild, you can use npm for that ... install esbuild ) - Since esbuild will bundle your code, it won't be packaged...
Read more >Getting started with esbuild - LogRocket Blog
You'll explore common use cases, from bundling TypeScript, React, image files, and CSS files to serving the bundling process as a server.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Node - v14.16.0 OS - macOS Catalina 10.15.17
This is the only library I’ve ever had this issue with.
I think you can just change
"import"
to"default"
if you don’t want a CJS copy. Or only enforce the rule at node side:I know the reason you’re doing this now is for telling people they cannot
require
the library. But in fact they can – when they have a bundler. Usingdefault
for exporting front-end files is a good practice since we must be careful enough to not including the same library twice (one ESM and another CJS). You can read more about dual package in Node.js’ doc.For a temporary workaround, you can always write an esbuild plugin / tsconfig.path to manaully resolve a file: