example-rollup-react-component-npm-package | Example React Component , Published to npm | Frontend Framework library
kandi X-RAY | example-rollup-react-component-npm-package Summary
kandi X-RAY | example-rollup-react-component-npm-package Summary
I've never used rollup before - hell, I've barely used webpack before. This was mostly to see how easy / difficult it was to create a React component package using rollup (aka "proof-of-concept"). My requirements for this package were.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of example-rollup-react-component-npm-package
example-rollup-react-component-npm-package Key Features
example-rollup-react-component-npm-package Examples and Code Snippets
Community Discussions
Trending Discussions on example-rollup-react-component-npm-package
QUESTION
I am trying to dynamically import react component library from API. The js file is fetched succesfully. The babel transpilation has happened successfully too. If I dynamically import the Dummy.js file from localhost like import Dummy from './components/js/Dummy.js'
, it works. However API import fails with below error. The same error occurs with react lazy too. I basically want to dynamically load the lib and publish events to it. I am newbie to react and front-end development. Please excuse if this is too silly!.
ANSWER
Answered 2020-Mar-27 at 05:56The rollup bundling configuration isn't correct. I was trying to create an es output with commonjs plugin while actually I required an esm module. The error on 'react' is because it is unresolved. Had to make it to use window.React while doing rollup bundle. Also, the App.js should be rolled up as esm bundle to make it dynamically import Dummy.js. In the HTML where app.js's bundle is included, I had to include react and react js umd scripts.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install example-rollup-react-component-npm-package
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page