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

Remix support #821

Open
mikecousins opened this issue Jan 12, 2024 · 6 comments
Open

Remix support #821

mikecousins opened this issue Jan 12, 2024 · 6 comments

Comments

@mikecousins
Copy link

import { Loader } from "@googlemaps/js-api-loader";
         ^^^^^^
SyntaxError: Named export 'Loader' not found. The requested module '@googlemaps/js-api-loader' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from '@googlemaps/js-api-loader';
const { Loader } = pkg;

Getting this error using Remix/ESM. Any idea how to get around this? The suggested config changes for nuxt/svelte don't work in Remix.

@mikecousins mikecousins added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jan 12, 2024
@wangela
Copy link
Member

wangela commented Jan 12, 2024

If you would like to upvote the priority of this issue, please comment below or react on the original post above with 👍 so we can see what is popular when we triage.

@mikecousins Thank you for opening this issue. 🙏
Please check out these other resources that might help you get to a resolution in the meantime:

This is an automated message, feel free to ignore.

@ahockersten
Copy link

@mikecousins you can put @googlemaps/js-api-loader in your serverDependenciesToBundle in remix.config.js in order to use this in Remix to get around this, see: https://remix.run/docs/en/main/file-conventions/remix-config#serverdependenciestobundle

@mikecousins
Copy link
Author

@ahockersten that's not available in certain Remix setups like Vite/SPA mode.

@mikecousins
Copy link
Author

Here's a good linter you can use to help fix the package: https://publint.dev/@googlemaps/js-api-loader

@johny
Copy link

johny commented Jul 29, 2024

Until this is properly fixed, this worked for me:

import * as pkg from "@googlemaps/js-api-loader";

@usefulthink
Copy link
Contributor

I'm using it all the time with exactly this import {Loader} from '...'; syntax without any problems.

An interesting point is, the error-message says The requested module '@googlemaps/js-api-loader' is a CommonJS module, which tells me that whatever bundler you're using isn't loading the ESM-version of the package but instead (presumably) the UMD-version.

I'm not sure if there is anything we can do about this, since it has probably something to do with the configuration of the bundler.

@usefulthink usefulthink removed type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. triage me I really want to be triaged. labels Oct 10, 2024
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.

5 participants