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

Commonjs export is not working #440

Open
nkemcels opened this issue Jan 2, 2024 · 1 comment
Open

Commonjs export is not working #440

nkemcels opened this issue Jan 2, 2024 · 1 comment

Comments

@nkemcels
Copy link

nkemcels commented Jan 2, 2024

I have a module which depends on cal-heatmap. In this module, I'm importing cal-heatmap via esm

import CalHeatmap from "cal-heatmap";
...

I'm bundling this module with webpack using the umd target and because I do not want the bundle size of the module to be large, I've externalize cal-heatmap.
Externalizing cal-heatmap causes it to be referenced in the module using the commonjs syntax, require("cal-heatmap");

But when I use the exported module in my project, the reference to cal-heatmap breaks the project. After hours of hair-pulling, I noticed that the global d3, d3-selection, d3-color and d3-fetch externalized in cal-heatmap is the root source of the issue. They are all undefined when imported with commonjs syntax

@FallingEpiphany
Copy link

change it into
import CalHeatmap from '@labzh/cal-heatmap'

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

No branches or pull requests

2 participants