-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
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
exports is not defined after build, works fine in dev mode #5142
Comments
With the typescript plugin being compiled with "module": "ESNext" in |
I have hacked a bit the
In that case, with the typescript plugin complied in ESNext, the Client build fine, the server fails with I came as temporary workaround to change the |
Hi, I'm not sure it can be considered a bug ,and don't even know what to do with this issue if I can't run/inspect any code that fails, so I'm closing it until it's proven there's a bug in Docusaurus. I'm willing to support you integrating Jupyter Notebook in Docusaurus, and we can continue the discussion here if you need help/support, but I'll need to see/run your code myself to be helpful. Also I'm not familiar at all with Jupyter Notebook 😅 |
Not sure at all if it is a bug, I have just followed the PR wizard... I think it is more a matter of webpack configuration. I agree a reproducer is needed and will provide one at some point. Feedback from the user land: Docusaurus is great and will be even greater with a few examples of typescript plugins. |
@echarles how did you fix the first error? Do you have a local Can you share the |
@tony My case was a docusaurus plugin for which I have defined the following configuration (no babel.config.js). It will not help as the configuration is very specific to my development, but here it is. export default function (
_context: LoadContext,
options: PluginOptions,
): Plugin<void> {
const isProd = process.env.NODE_ENV === 'production';
return {
name: 'docusaurus-plugin-jupyter',
getThemePath() {
return path.resolve(__dirname, './theme');
},
configureWebpack(_config: Configuration, isServer: boolean) {
return {
mergeStrategy: {
'module.rules': 'prepend',
'plugins': 'prepend',
},
module: {
rules: [
{
test: /.*lib0.*\.m?js/,
resolve: {
fullySpecified: false
}
},
],
},
plugins: [
new ProvidePlugin({
process: 'process/browser'
}),
]
};
},
};
} |
@echarles thank you - i will look at it as an example / for inspiration To clarify, that config is your docusaurus.config.js? I'm not that code is for. It seems to be a docusaurus plugin? |
@tony This is some code for a docusuarus plugin in the |
I ran into the exact same issue as @echarles. The Docusaurus plugin I was developing ran fine in development mode but broke with the After much trial and error, the cause in my own plugin seems to be using a React class component as a Docusaurus theme element. When I refactored the component into a React function component instead, the plugin built and ran in production with no problems. For reference, this file here from my plugin breaks the output from Leaving this comment for anyone else who stumbles across this issue. |
@davidtimmons Your problem is because you have set Sometimes Webpack seems to be able to understand Related issue: #2074 |
@Josh-Cena: Thank you for pointing out the upcoming architecture diagram and the Algolia package. They are both illuminating. I quite like the structure of the Algolia package. After refactoring my plugin to incorporate the two separate module structures suggested in these resources, I can confirm that React class and function components both work equally well with Docusaurus theme files. As you say, what I originally suspected must just be an artifact of how Webpack works. I appreciate the tips! |
🐛 Bug Report
Prerequisites
npm run clear
oryarn clear
command.rm -rf node_modules yarn.lock package-lock.json
and re-installing packages.Description
I am developing a plugin to embed jupyter notebook into docusaurus (see screenshot below). The dependencies developed in Typescript and built with 'module: commonjs
. This works fine with
docusaurus start(dev mode). I can also build fine with
docusaurus build. However, when I run
docusaurus serve, I receive
ReferenceError: exports is not defined`. The relevant block code is pasted after the images.The text was updated successfully, but these errors were encountered: