Closed kungfooman closed 2 months ago
From this thread: https://forum.playcanvas.com/t/how-to-add-the-pcui-package-to-a-react-app/22289/4
I tested around with conditional exports in package.json first: https://nodejs.org/api/packages.html#packages_conditional_exports
package.json
"exports": { "import": "./index.mjs", "require": "./index.js" }
But then I realized react-scripts (using webpack) is ignoring that and I just had to remove those two lines to make it work:
react-scripts
webpack
https://github.com/playcanvas/playcanvas-observer/blob/6c1ae13c222e8c640252a25979e487c71a57d71f/package.json#L5-L6
Now it works for require and import case, require test via node itself:
require
import
node
But I don't know if that breaks other setups, while it works with webpack... everybody is using a different bundler with different import rules and whatnot.
I believe this is now fixed. I added publint support to the repo today and it reports no problems. Closing.
publint
From this thread: https://forum.playcanvas.com/t/how-to-add-the-pcui-package-to-a-react-app/22289/4
I tested around with conditional exports in
package.json
first: https://nodejs.org/api/packages.html#packages_conditional_exportsBut then I realized
react-scripts
(usingwebpack
) is ignoring that and I just had to remove those two lines to make it work:https://github.com/playcanvas/playcanvas-observer/blob/6c1ae13c222e8c640252a25979e487c71a57d71f/package.json#L5-L6
Now it works for
require
andimport
case,require
test vianode
itself:But I don't know if that breaks other setups, while it works with webpack... everybody is using a different bundler with different import rules and whatnot.