-
Notifications
You must be signed in to change notification settings - Fork 299
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
ESM build cannot be loaded by Node.js #3155
Comments
@brillout Can you confirm which versions of Node you're seeing this in? From your example, it looks like you've primarily tested Node 18, is that correct? |
That is correct
…On Mon 12. Dec 2022 at 18:25, Scott Rees ***@***.***> wrote:
@brillout <https://github.com/brillout> Can you confirm which versions of
Node you're seeing this in? From your example, it looks like you've
primarily tested Node 18, is that correct?
—
Reply to this email directly, view it on GitHub
<#3155 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAHVQRXD76Y5AI55KOQ2WKTWM5NW7ANCNFSM6AAAAAAS2JF2AU>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Thank you. I was able to reproduce it with NodeJS 16 |
type module isn't required; better and simpler would be to make ESM files have an |
Just an update that we are making progress on this and will have a PR out soon. |
@brillout @micah-redwood @johanhenrikssn @sheremet-va @ljharb We've published the fix for this to a
I've tested it out with https://github.com/brillout/aws-amplify-bug-esm-build and it appears to be working. |
The ESM fix has been released in
@brillout @ljharb @micah-redwood, @johanhenrikssn, @sheremet-va, please let us know if it's working for you. |
Thanks @reesscot , it's working great for me (using Vite 3.2.3)! And hopefully eventually we can get rid of the Vite workarounds mentioned in this issue: |
So glad to hear ESM in NodeJS is working for you @micah-redwood! We are also working on fixing the remaining vite issues as well, which can be tracked in the ticket you linked. |
Before creating a new issue, please confirm:
On which framework/platform are you having an issue?
React
Which UI component?
Authenticator
How is your app built?
Vite + vite-plugin-ssr
What browsers are you seeing the problem on?
Chrome
Please describe your bug.
Node.js cannot import
@aws-amplify/ui-react
:The fix is to set
"type": "module"
innode_modules/@aws-amplify/ui-react/package.json
, but then another error is thrown:The problem here is that
node_modules/@aws-amplify/ui-react/dist/esm/primitives/Collection/Collection.js
containsimport a from"lodash/debounce"
but it should beimport a from"lodash/debounce.js"
instead. (If you change that line, you'll see the error go away but another similar error is thrown then.)What's the expected behaviour?
No errors.
Help us reproduce the bug!
Minimal reproduction: https://github.com/brillout/aws-amplify-bug-esm-build.
(In case you're curious, this is the real-world reproduction: https://github.com/micah-redwood/vite-prerender-aws-amplify-compat. With the Vite workaround I mention down below: https://github.com/brillout/vite-prerender-aws-amplify-compat.)
Code Snippet
No response
Additional information and screenshots
I'm the author of vite-plugin-ssr; one of my users reported this bug.
For Vite, a workaround is to add
@aws-amplify/ui-react
tovite.config.js.noExternal
.But other stacks don't have this possibility, e.g. companies that implement SSR themselves without using a bundler such as Vite or webpack. See the minimal reproduction.
Possibly related: aws-amplify/amplify-js#11421. (Since SvelteKit uses Vite.)
The text was updated successfully, but these errors were encountered: