This repository has been archived by the owner on Feb 18, 2024. It is now read-only.
@neutrinojs/react-components expects prop-types to be available in build #1457
Labels
Milestone
Bug
What did you do?
<script src="/static/HelloWorld.js"></script>
window.React
What did you expect to happen?
require
is not defined see Allow using @neutrinojs/react-components output directly in the browser #1425 - this issue is NOT about the require being needed.I expected that prop-types are stripped from the build because of this code, which react-components uses:
https://github.com/neutrinojs/neutrino/blob/master/packages/react/index.js#L28
Instead, I think what is happening is that that the webpack-node-externals is somehow thinking that the project needs prop-types because of its default behaviour call when used here:
https://github.com/neutrinojs/neutrino/blob/master/packages/react-components/index.js#L63
I think the actual prop-types are being stripped, but maybe that happens AFTER the
require
calls are added in the build process. I do not really know enough about webpack to know for sure but if I skip that step and define my own externals via a custom preset at the end, prop-types is not required.Work around + potential source of the problem
This code below solves the 'require' problem but as an aside, overriding the output in config.externals that is set by webpack-node-externals seems to resolve the issue of prop-types being expected to be available.
eg.
The text was updated successfully, but these errors were encountered: