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

Issue when bundling #137

Open
shankar-n-subramanian opened this issue Oct 8, 2021 · 2 comments
Open

Issue when bundling #137

shankar-n-subramanian opened this issue Oct 8, 2021 · 2 comments

Comments

@shankar-n-subramanian
Copy link

shankar-n-subramanian commented Oct 8, 2021

Hi,

  1. Firstly, thanks for this amazing lib.

  2. The lib works all fine when run locally (development setup), however when bundled, I see there is an issue as below when run from server (tomcat).

Uncaught ReferenceError: require is not defined
    at Object.<anonymous> (vendor.34adf1bb1fb42a79e6c9.js:2)

I am sure its something got to do with webpack config or so.. Could you please let me know what is that I could be missing that it is showing up this error.

  1. Can you please share the webpack config that ensures the bundling is not borken?

Note: in development setup, I do not see this error as node takes care of rendering it.

Thanks,
Shankar

@jmaurid
Copy link

jmaurid commented Dec 17, 2024

Hi!

I have a similar situation right now, did you get this resolved?

@shankar-n-subramanian
Copy link
Author

Hi!

I have a similar situation right now, did you get this resolved?

Hi,

Uncaught ReferenceError: require is not defined at Object.<anonymous> (vendor.34adf1bb1fb42a79e6c9.js:2)
This issue is because the lib require is not recognized as it was not transpiled as part of the production build.

Please check if your webpack.config.js has any option to ignore the .min.js files? If so, go ahead and comment/remove that out and try once.

module.exports = function () {
     .....
     .....
     .....

     /*config.module = {
        noParse: /\.min\.js/
    };*/
     .....
     .....
}

There may be a better way to get this done, but for getting things to work this is what had to be done.

Additional information (in case you are facing building of react code):
I had trouble to get build working and it is all got to do with configuring the webpack.config.js. I had to add the below in the webpack.config.js to let know the webpack to include any files with "ts|tsx|js|jsx" extension within the folder './src/main/javascript/v2/' (where the react code resides) to transpile and include in the final bundle.

Please ensure to add the below mentioned babel libs in devDependencies

{
test: /.(ts|tsx|js|jsx)$/,
exclude: /(node_modules|bower_components)/,
use: {
loader: 'babel-loader',
options: {
presets: [['@babel/preset-env', {modules: false}], '@babel/preset-react'],
include: './src/main/javascript/v2/',
plugins: ['@babel/plugin-transform-runtime']
}
}
}

Hope this helps!

Regards,
Shankar

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