Comments (22)
yeah buddy. i'll give it a shot.
from reaviz.
I don't wanna get too far ahead of myself, but d3 might have solved the problem for us.
The specific dep that's throwing the error for me is d3-array, and according to your package.json, you have v3.0.4, and there is a new version, 3.1.1 available as of 1 month ago. According to the changelog, they have updated it to es6, so import should actually work now.
I'll report back after some testing.
from reaviz.
I think CRA supports ESM and transpilation out of the box (unlike Next.js and other tools).
Deleting NPM lock and re-installing did not solve the issue ☹
from reaviz.
OK - I bumped the version to a major so others are aware. I don't know the fix yet though. REAVIZ does have a CJS version but I don't know why the d3-* packages are being difficult. I will keep digging in and let me know if you find anything.
from reaviz.
Great news - glad you were able to resolve it. Let the group know if you find any of suggestions for this!
from reaviz.
@dpranav007 - Thanks for the ping. The comment in that ticket is very helpful. I need to research an alternative build configurations and in the meantime if u find anything relevant post in this thread.
from reaviz.
In the end managed to get it working with dynamic imports, probably not ideal but at least it's a workaround 🤷🏼
This is still an issue for with next
version 12.1.0
(and reavis 13.0.4
) but I've got a much simpler work around for anyone coming across this:
import dynamic from "next/dynamic";
const BarChart = dynamic(() => import("reaviz").then((mod) => mod.BarChart), {
ssr: false,
});
Next docs. The SSR :false
option seems to fix this issue (at the obvious cost of not rendering on the server)
from reaviz.
@botre - sorry to hear about the issue. let me provide some feedback below.
Is this an ESM-first module now?
It shouldn't be. In the latest release, I upgraded the d3-
dependencies which are ESM now, however, these are bundled with the project so they shouldn't be causing this issue.
In my opinion, this should be clearly stated in the documentation.
100% - I did not realize this was happening. If it was I would have documented and bumped major version.
I'm running the project in 2 different CRA applications and not seeing this error. Did you manually include those deps? Can you try deleteing your yarn/npm lock and reinstalling?
from reaviz.
I have created a minimal reproduction for this issue, see this repo: https://github.com/botre/reaviz-next-repro
from reaviz.
Thank you - Im digging into this - will let you know tomorrow how we can proceed
from reaviz.
Let me know if there is anything I can help with.
from reaviz.
Hey! Just found this thread, same issue. Has there been a resolution? I am up for a bug hunt if help is required
from reaviz.
@jazznerd206 No resolution yet - any help would be greatly appreciated!
from reaviz.
Ya - This started when d3-* made their packages ESM and since its a dep of reaviz if your app isn't setup to handle esm then the error happens.
from reaviz.
@amcdnl Hey, so it turns out that was exactly my problem, not a problem with reaviz!!
my fix was as follows:
webpack.config.js
{ test: /\b.json\b/, loader: 'json-loader', },
sorry for conflating my mistake with your package!!
from reaviz.
reactviz
is also breaking on latest Next (12.0.7) which is supposed to support ESM by default.
In the end managed to get it working with dynamic imports, probably not ideal but at least it's a workaround 🤷🏼
import dynamic from "next/dynamic";
const Component = () => {
const [CalendarHeatmap, setCalendarHeatmap] = useState<any>(null);
useEffect(() => {
// mod.* can be anything you would normally import like BarChart, LineChart etc
const DynamicCalendarHeatmap = dynamic(() => import('reaviz' as any).then(mod => mod.CalendarHeatmap))
if(DynamicCalendarHeatmap) {
setCalendarHeatmap(DynamicCalendarHeatmap)
}
}, [])
return (
<div>
{CalendarHeatmap && <CalendarHeatmap data={calendarData} height={300} width="auto"/>}
</div>
);
}
"reaviz": "^11.1.2",
"next": "^12.0.7",
Tried to debug the issue but no success on my end either. Here is what I tried:
- use
next-transpile-modules
innext.config.js
- still broken - removed
cjs
from rollup (including commonJs plugin) - still broken - use @jazznerd206 solution - still broken
- bumped
d3-array
to3.1.1
- still broken - for science went with
experimental.esmExternals = true
innext.config.js
even though it'strue
by default since12.x.x
(may as well try that at this point lol) - still broken - change
rollup-plugin-commonjs
to@rollup/plugin-commonjs
- still broken - downgraded to
[email protected]
and tried out with and withoutexperimental.esmExternals = true
- still broken - tried urlImports with
https://cdn.skypack.dev/reaviz
- still broken
At that point the only thing that left besides dynamic import
in my mind was to dig in the source maps but didn't bother once I got it working
from reaviz.
@sbsrnt - Thanks for the detailed report. I'm open to suggestions on ways to address this - I'm not sure what the best path is though.
from reaviz.
@amcdnl Could you please check this for the issue. Thanks
vercel/next.js#33901 (comment)
from reaviz.
Hi I've tried using @zischwartz solution but it's not working when I try to import LinearXAxis and LinearYAxis. Below is my code.
const BarChart = dynamic(() => import('reaviz').then(mod => mod.BarChart), {ssr: false});
const BarSeries = dynamic(() => import('reaviz').then(mod => mod.BarSeries), {ssr: false});
const LinearXAxis = dynamic(() => import('reaviz').then(mod => mod.LinearXAxis), {ssr: false});
const LinearYAxis = dynamic(() => import('reaviz').then(mod => mod.LinearYAxis), {ssr: false});
const data = [
{key: "PowerShell - T1059", data: 150},
{key: "Remote Desktop Protocol - T1021", data: 200},
{key: "Data Encrypted for Impact - T1486", data: 300}
]
export default function MitreBarChart() {
return (
<BarChart
data={data}
xAxis={<LinearXAxis type="value"/>}
yAxis={<LinearYAxis type="category"/>}
series={<BarSeries layout="horizontal"/>}
/>
)
}
This is the error:
As we can see from the call stack, the error is coming from the isAxisVisible function, which is trying to read the props from LinearXAxis or LinearYAxis. I can't figure out why they are undefined.
Can anyone advise on how to fix this?
from reaviz.
I'm happy to implement any suggestion someone might have, I just don't know the best way to fix this. I've also not hit it but I'm not doing NEXT/etc.
from reaviz.
same issue, not work in cra with ssr:
module.exports = require("d3-time-format");
Error [ERR_REQUIRE_ESM]: require() of ES Module .../node_modules/d3-time-format/src/index.js from .../build/server.js not supported.
[1] Instead change the require of index.js in .../build/server.js to a dynamic import() which is available in all CommonJS modules.
from reaviz.
Please give this a try again!
from reaviz.
Related Issues (20)
- Scatter Plot Grid Lines missing stripe HOT 1
- Custom Value Labels HOT 1
- Line Chart Vertical Markers HOT 2
- Line and Area Horizontal Markers
- Funnel Chart Enhancements HOT 2
- Next.js - Generating static page fails HOT 2
- Meter component issue
- Feature request for Segmented Scattered plots
- Custom Label Rotation Broken HOT 1
- Support for defaultProps will be removed from function components in a future major release. Use JavaScript default parameters instead HOT 2
- Extend RadialGaugeSeries or create new one with ability to display sectors on the same line #83
- Chart flicker on initial rendering
- Better documentation for custom charts
- Tooltip does not remain at point location, follows user on scroll (Touch devices) HOT 2
- Hover causes everything to disappear
- Chart position with linear axis
- Scatter Plot - Trend Line HOT 3
- Bar Chart fill issues
- Module not found error with tailwindcss HOT 3
- Got same key issue with AreaChart with multi-series & type=grouped HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from reaviz.