I am basically trying to do a poc
on extracting the some part of my main application into a separate package.A Sample separate package I have built it in my git repo myapp-poc-ui.
Now I am trying to access this in my main application.
package.json :
"dependencies": {
"myapp-poc-ui": "git+https://github.com/prabhatmishra33/myapp-poc-ui#master",
"react": "^16.10.1",
"react-dom": "^16.10.1",
"react-scripts": "3.2.0"
},
I am accessing the exported module in my main app by:
import React from 'react';
import './App.css';
import { HelloWorld } from "myapp-poc-ui";
import { LazyComponent } from "myapp-poc-ui";
function App() {
return (
<div>
<HelloWorld />
<LazyComponent />
</div>
);
}
export default App;
Issue : I am getting an issue on my browser
Uncaught SyntaxError: Unexpected token '<'
Uncaught (in promise) ChunkLoadError: Loading chunk 1 failed.
Hello World
gets loaded properly but this issue comes while loading the LazyComponent
.
I am guessing there is something wrong in webpack config file publicPath property
for myapp-poc-ui
Any design change suggestion is also welcome.
Thanks in advance.