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

[Bug] module not found when dynamically importing milkdown/prose/* into Next.js 13 application #1695

Open
2 tasks done
helenlu2001 opened this issue Feb 18, 2025 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@helenlu2001
Copy link

Initial checklist

  • I agree to follow the code of conduct
  • I searched issues and discussions and couldn’t find anything (or linked relevant results below)

Affected packages and versions

milkdown/prose/*

Link to runnable example

No response

Steps to reproduce

Hi, I'm trying to dynamically import components from @milkdown/prose/* into my Next.js 13 application.`

import dynamic from 'next/dynamic';
const Slice = dynamic(() => import('@milkdown/prose/model').then(mod => mod.Slice), {
  ssr: false,
});
const CellSelection = dynamic(
  () => import('@milkdown/prose/tables').then(mod => mod.CellSelection),
  { ssr: false },
);

However, it's erroring out when I run next build
Module not found: Package path ./tables is not exported from package /home/circleci/project/frontend/node_modules/@milkdown/prose (see exports field in /home/circleci/project/frontend/node_modules/@milkdown/prose/package.json)


As an aside, the initial reasoning for introducing the dynamic imports was that I was running into the following issue during next build when I upgraded my application from Next.js 12 to Next.js 13.

TypeError: Cannot use 'in' operator to search for 'webkitFontSmoothing' in undefined
    at file:///home/circleci/project/frontend/node_modules/@milkdown/prose/node_modules/prosemirror-view/dist/index.js:176:47
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async importModuleDynamicallyWrapper (node:internal/vm/module:431:15)

Expected behavior

@milkdown/prose/* should be correctly resolved especially since it is listed in the "exports" of the package.json

Actual behavior

I'm running into the following errors when I run next build

Module not found: Package path ./tables is not exported from package /home/circleci/project/frontend/node_modules/@milkdown/prose (see exports field in /home/circleci/project/frontend/node_modules/@milkdown/prose/package.json)

ModuleNotFoundError: Module not found: Error: Package path ./model is not exported from package /root/project/frontend/node_modules/@milkdown/prose (see exports field in /root/project/frontend/node_modules/@milkdown/prose/package.json)

Runtime

Chrome

OS

Linux

Build and bundle tools

Next.js

@helenlu2001 helenlu2001 added the bug Something isn't working label Feb 18, 2025
@Saul-Mirone
Copy link
Member

Saul-Mirone commented Feb 19, 2025

Please provide a minimal reproduction.

@helenlu2001
Copy link
Author

The repo I'm working with is very large, but I'll try to make a minimal reproduction and get back to you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants