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] <title> 使用 @codesandbox/sandpack-react报错 #2469

Closed
1 task done
rxyshww opened this issue Sep 3, 2024 · 5 comments
Closed
1 task done

[BUG] <title> 使用 @codesandbox/sandpack-react报错 #2469

rxyshww opened this issue Sep 3, 2024 · 5 comments

Comments

@rxyshww
Copy link

rxyshww commented Sep 3, 2024

Is there an existing issue for this?

  • I have searched the existing issues

Which Component

No response

Semi Version

No response

Current Behavior

Something went wrong

/App.js: Could not find module in path: 'vfile/lib/#minpath' relative to '/node_modules/vfile/lib/index.js' (3:0)

1 |
2 | import React from "react";

3 | import { Button } from '@douyinfe/semi-ui';
^
4 |
5 | export default function App() {
6 | return (

Expected Behavior

No response

Steps To Reproduce

https://codesandbox.io/p/sandbox/r7gdwm

ReproducibleCode

"use client";
import React from "react";
import { Sandpack } from "@codesandbox/sandpack-react";

const code = `
import React from "react";
import { Button } from '@douyinfe/semi-ui';

export default function App() {
  return (
    <>
        <Button type='primary'>primary button</Button>
    </>
  );
}
`;

const SandpackExample = () => {
  return (
    <Sandpack
      template="react"
      files={{
        "/App.js": code,
      }}
      customSetup={{
        dependencies: {
          "@douyinfe/semi-ui": "latest",
        },
      }}
    />
  );
};

export default SandpackExample;

Environment

- OS:
- browser:

Anything else?

No response

@pointhalo
Copy link
Collaborator

pointhalo commented Sep 4, 2024

This is a problem with the bundle of codesandbox, which we cannot solve.
It may use a low-version bundle, such as a low-version of rollup or a low-version of webpack, which cannot recognize the Subpath imports syntax and will cause problems.

The dependency vfile of mdx uses this syntax.。
image
image

@pointhalo
Copy link
Collaborator

pointhalo commented Sep 4, 2024

Not familiar with the @codesandbox/sandpack-react package. If you can config its bundle process, you can also configure an alias to solve the problem. The problem is essentially that its bundle cannot correctly identify the import path.

@pointhalo
Copy link
Collaborator

The examples here all have the same problem: https://codesandbox.io/examples/package/vfile

@pointhalo
Copy link
Collaborator

image
Another solution is to try to lock the vfile version to 6.0.1
This syntax is used in versions 6.0.2 and later.
Explicitly declaring the version of this dependency to be 6.0.1 should also solve this problem
image

@pointhalo
Copy link
Collaborator

We have reported this issue to codesandbox. Whether it will be fixed later depends on their team's decision.

codesandbox/codesandbox-client#8625

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