Hi! Please, reply on a weekday :slightly_smiling_f...
# gooddata-ui
Hi! Please, reply on a weekday 🙂 I’ve decided to try the new SDK9 on a rainy Saturday, which means switching our project to ESM. First I encountered the following error:
Copy code
TypeError: Module "file:///[redacted]/node_modules/.pnpm/@gooddata+sdk-ui-dashboard@9.0.0_@types+node@18.13.0_@types+react@18.0.26_react-dom@18.2.0_re_e4ghvbd4tvwc33wq4c5t4brfhy/node_modules/@gooddata/sdk-ui-dashboard/esm/presentation/localization/bundles/en-US.json" needs an import assertion of type "json"
    at new NodeError (node:internal/errors:400:5)
I’m running Node 18.3.0. I’m not importing that json file anywhere in application code, so the issue is in your lib. I had to look find all places where you import JSONs and add that assertion. Then it went through, but I landed on the following error:
Copy code
import { colors2Object, numberFormat } from "@gooddata/numberjs";
SyntaxError: Named export 'colors2Object' not found. The requested module '@gooddata/numberjs' is a CommonJS module, which may not support all module.exports as named exports.
I’ve got version 4.1.0 of @gooddata/numberjs, which seems to be the latest one, so I think you forgot to convert that one to ESM. My hunch is that you’ve never tested the library in a pure ESM environment and always used some bundler that covered these up and in the end it’s not truly ESM ready.
Hi Tomáš, I'll look into this and see what I can see on this rainy Monday 🙂
🌧️ 1
👍 1
Thanks, Radek! My feeling is, that there’s gonna be a lot more things to fix, but I didn’t go down the rabbit hole 🙂 A lot of npm packages are still commonjs, so my guess is this won’t end with
. However, you can still use those cjs packages in your esm package, you just can’t use named exports from cjs. So you’d have to change
import { colors2Object, numberFormat } from "@gooddata/numberjs"
import numberjs from "@gooddata/numberjs"; const { colors2Object, numberFormat } = numberjs
. Of course, as you have control of the numberjs package, you should change it to esm, but you can use this for other cjs packages you wish to use.
Just an update so we know where we're at - Tomas has managed a workaround for this issue, and in the meantime our engineers are working to fix the issue itself. 🙂