-
-
Notifications
You must be signed in to change notification settings - Fork 885
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
Module "assert" has been externalized for browser compatibility and cannot be accessed in client code. #632
Comments
Vite seems to specify that, in development, development code is loaded: https://github.com/vitejs/vite/blob/ed16488591b7dfac7e54d96f67c6f3674368b0cc/packages/vite/src/node/plugins/resolve.ts#L654. |
This comment has been minimized.
This comment has been minimized.
but I never config ,here is my vite.config.ts: export default () => {
return {
// css 预处理器
css: {
preprocessorOptions: {
less: {
javascriptEnabled: true,
},
},
},
// 别名
resolve: {
},
// 接口代理
server: {
proxy: {
},
},
// 打包
build: {
rollupOptions: {
cssCodeSplit: true,
},
outDir: currConf.outputPath,
commonjsOptions: { transformMixedEsModules: true },
},
// 插件
plugins: [
reactRefresh(),
checker({
typescript: true,
overlay: false,
// enableBuild: false,
eslint: { files: ['./src'], extensions: ['.ts', '.tsx'] },
}),
],
};
}; |
vitejs/vite#4479 (comment) suggests using browserify polyfills. |
getting the same error with webpack 5, why is the issue closed? |
because it’s not an issue here, but with how your bundler is configured. |
Hi @Snnny where you able to fix your issue? Because I'm running into the same issues in my dev environment and hasn't been able to figure out how to fix it 🤔 Update I got mine working by install this assert package as a dev dependency and adding a
But interested to know if anyone has a smarter solution? |
true, but I would expect a frontend library to avoid relying on node.js modules
this is how I solved it:
|
Well, its a bit more complex because: |
I'm using browserify |
micromark does not include |
Wow, that's great to hear. |
@JounQin can you share your config file so I can see how you use the assert polyfill? |
about `assert`: remarkjs/react-markdown#632
Closes GH-87. Related to: remarkjs/react-markdown#632. Related to: remarkjs/react-markdown#641. Related to: remarkjs/remark#831.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Correct, it does. Which was higher than the one you had! I’ll hide this subthread, for further readers: remove your locks and install again and you won’t hit this old issue! |
Initial checklist
Affected packages and versions
7.0.0
Link to runnable example
No response
Steps to reproduce
import ReactMarkdown from 'react-markdown';
import remarkGfm from 'remark-gfm'
<ReactMarkdown children={'# hello'} remarkPlugins={[remarkGfm]}>
Expected behavior
show hello
Actual behavior
Uncaught Error: Module "assert" has been externalized for browser compatibility and cannot be accessed in client code.
at Object.get (browser-external:assert:3)
at go (create-tokenizer.js:213)
at main (create-tokenizer.js:198)
at Object.write (create-tokenizer.js:124)
at fromMarkdown (index.js:117)
at parser (index.js:15)
at Function.parse2 [as parse] (index.js:273)
at ReactMarkdown (react-markdown.js:102)
at renderWithHooks (react-dom.development.js:14985)
at mountIndeterminateComponent (react-dom.development.js:17811)
Runtime
Node v12
Package manager
yarn v1
OS
macOS
Build and bundle tools
Vite
The text was updated successfully, but these errors were encountered: