-
-
Notifications
You must be signed in to change notification settings - Fork 24
Next.js Support? #31
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
npm install next-remove-imports
npm install @uiw/react-textarea-code-editor@v1.4.4 // next.config.js
const removeImports = require("next-remove-imports")();
module.exports = removeImports({
experimental: { esmExternals: true }
}); import React from "react";
import dynamic from "next/dynamic";
import "@uiw/react-textarea-code-editor/dist.css";
const CodeEditor = dynamic(
() => import("@uiw/react-textarea-code-editor").then((mod) => mod.default),
{ ssr: false }
);
function HomePage() {
const [code, setCode] = React.useState(
`function add(a, b) {\n return a + b;\n}`
);
return (
<div>
<CodeEditor
value={code}
language="js"
placeholder="Please enter JS code."
onChange={(evn) => setCode(evn.target.value)}
padding={15}
style={{
fontSize: 12,
backgroundColor: "#f5f5f5",
fontFamily:
"ui-monospace,SFMono-Regular,SF Mono,Consolas,Liberation Mono,Menlo,monospace"
}}
/>
</div>
);
}
export default HomePage; |
This line still seems to be problematic:
If I remove that line, I still get another error:
If I change |
@codeXLinkX Upgrade |
Do I still need to keep dist.css import after upgrading to 1.4.7? Because I still get
after this change:
|
I wonder if the example only works because the css was imported in a file under the /pages folder. I am importing it outside /pages so it probably doesn't run in the server side. |
I'm not sure what you mean. |
For my own learning: @jaywcjlove could you please explain why the following
|
The next-remove-imports plugin removes the css files(in node_modules) introduced in the package, and nextjs(CSS Imported by a Dependency) will not report an error. |
@jaywcjlove Thank you for the quick reply! However, it still unclear to me why the |
@MariaSolOs yes i didn't think about adding "main": "cjs/index.js",
"module": "esm/index.js",
"exports": {
".": {
"import": "./esm/index.js",
"require": "./cjs/index.js"
},
"./index": {
"import": "./esm/index.js",
"require": "./cjs/index.js"
}
".": {
"import": "./esm/index.js",
"require": "./cjs/index.js"
},
"./shortcuts": {
"import": "./esm/shortcuts.js",
"require": "./cjs/shortcuts.js"
},
"./styles": {
"import": "./esm/styles.js",
"require": "./cjs/styles.js"
},
"./SelectionText": {
"import": "./esm/SelectionText.js",
"require": "./cjs/SelectionText.js"
},
"./utils": {
"import": "./esm/utils.js",
"require": "./cjs/utils.js"
}
} react-textarea-code-editor/package.json Lines 5 to 7 in 7e75adf
|
@jaywcjlove Yeah I think that adding that |
@MariaSolOs Tested, the style can't automatically load the rollback code. |
* feat: DB 구조와 API docs를 참고한 공통 인터페이스 구현 및 적용 * refactor: PostCommentRequest 구현 * feat: api 스펙 변경에 맞춘 네이밍 변경 * feat: SelectOption에 이미지 추가 - image mock data 추가 - 버튼으로 태그 변경 * refactor: style -> styles * feat: CodeEditor 추가 * feat: 코드블럭 추가 * fix: 그라데이션 넓이 유동적으로 변경 * refactor: codeblock mockdata화 * test: CodeEditor에 대한 props 정의 * fix: dark 모드 적용 * feat: next에서 사용 가능하도록 변경 uiwjs/react-textarea-code-editor#31 (comment) * fix: 코드 블록에 스타일 제대로 안먹던 문제 해결 * fix: 쓸데없는 tab 제거 * fix: 폰트 변경이 정상적으로 작동하지 않던 문제 해결
Is Nevemind I was missing this in my imports: import "@uiw/react-textarea-code-editor/dist.css"; the example should add this |
Im using the same example posted in the Readme, for working with the last version of Nextjs using app routing, and doesnt work it gives me the same error of modules
|
@JM-delatorre Example: https://github.com/uiwjs/next-remove-imports/tree/main/example |
Im not sure what is the problem, but i re installed the two packages without the versioning tag, and in the component that i am working on i specified that is a client and not a server component. I solved it this way but im not sure why it works. btw thanks for the fast response. |
@JM-delatorre Thanks for your comment, that helped me. I added |
Using "next": "13.4.13", I also had to add: to my |
I had to do |
When I try to use this package in a React/Nextjs project, I get the following errors:
Module not found: ESM packages (rehype) need to be imported. Use 'import' to reference the package instead. https://nextjs.org/docs/messages/import-esm-externals
and
The link in the error message suggests the following:
So I wanted to hear the thoughts of the maintainers of this package. Thanks!
The text was updated successfully, but these errors were encountered: