Closed sanidayalgupta closed 2 weeks ago
I don't get why you get such error given the import from dayjs/esm
.
Make sure to import the exact file path, do not rely on Node/other bundlers magic, the WDS doesn't do magical resolve out of the box. E.g. in your case you can try
import dayjs from "dayjs/esm/index.js";
If mermaid
is importing dayjs
and uses the CommonJS file instead of the ESM, which is often happening when libraries don't specify exports for both CommonJS and ESM, then you might try the CommonJS plugin for WDS https://modern-web.dev/guides/dev-server/using-plugins/#commonjs
Still getting same error after importing like this import dayjs from "dayjs/esm/index.js";
I have tried wds configuration by using import { fromRollup } from "@web/dev-server-rollup"; import rollupCommonjs from "@rollup/plugin-commonjs";
const commonjs = fromRollup(rollupCommonjs);
export default /* @type {import('@web/dev-server').DevServerConfig} / ({ open: "/", appIndex: "index.html", watch: true, nodeResolve: true,
plugins: [ commonjs({ include: [ "/node_modules/dayjs//", "/node_modules/@braintree/sanitize-url//", ], }), ], });
This is also not working, Any idea ?
Please debug it. It doesn't look like a bug on our side. If you believe it is a bug, please make a minimal reproduction and push to a repository on GitHub with simple steps to reproduce.
Hi All,
I am getting below error while importing mermaid.
Uncaught SyntaxError: The requested module './../../dayjs/dayjs.min.js' does not provide an export named 'default' (at mermaid-6dc72991.js:2:8)
I have imported like this import mermaid from "mermaid"; import dayjs from "dayjs/esm";
Please let me if any solution is there.