I am trying to add a new script in my react app for creating a library which is built using create-react-app 4.x . My config-overrides.js is configured as per the documentation of react-app-rewire-create-react-library . When running the build-library command ,a build is generated for the library as
File sizes after gzip:
763 B build/index.js
175 B build/static/js/my-library.27978dae.chunk.js
My package.json content:
module:src/module.js
main:build/index.js
I am trying to use this library in other React Application using local-package-publisher https://www.npmjs.com/package/local-package-publisher , none of the modules seem to be properly exported. An exported module comes as undefined upon usage.
We do not find any reference to the static folder which is generated as part of build. We checked the static folder and it does have the content of the functions that we are trying to export.
Can you help us with this query. And also can we configure the package in a way that it creates the final build such that entire bundled content comes in one file index.js.
react-app-rewire-create-react-library is no longer maintained, and was written for Webpack 2/3. My understanding is that it will no longer work on react-scripts 2+, or react-app-rewired 2+.
I am trying to add a new script in my react app for creating a library which is built using create-react-app 4.x . My config-overrides.js is configured as per the documentation of react-app-rewire-create-react-library . When running the build-library command ,a build is generated for the library as
File sizes after gzip: 763 B build/index.js 175 B build/static/js/my-library.27978dae.chunk.js
My package.json content:
module:src/module.js main:build/index.js
I am trying to use this library in other React Application using local-package-publisher https://www.npmjs.com/package/local-package-publisher , none of the modules seem to be properly exported. An exported module comes as undefined upon usage.
Content of index.js comes as follows:
!function(e){function t(t){for(var n,i,l=t[0],a=t[1],p=t[2],c=0,s=[];c<l.length;c++)i=l[c],Object.prototype.hasOwnProperty.call(o,i)&&o[i]&&s.push(o[i][0]),o[i]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(f&&f(t);s.length;)s.shift()();return u.push.apply(u,p||[]),r()}function r(){for(var e,t=0;t<u.length;t++){for(var r=u[t],n=!0,l=1;l<r.length;l++){var a=r[l];0!==o[a]&&(n=!1)}n&&(u.splice(t--,1),e=i(i.s=r[0]))}return e}var n={},o={1:0},u=[];function i(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.m=e,i.c=n,i.d=function(e,t,r){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},i.r=function(e){"undefined"!==typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"===typeof e&&e&&e.esModule)return e;var r=Object.create(null);if(i.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)i.d(r,n,function(t){return e[t]}.bind(null,n));return r},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="/";var l=this["webpackJsonpmy-library"]=this["webpackJsonpmy-library"]||[],a=l.push.bind(l);l.push=t,l=l.slice();for(var p=0;p<l.length;p++)t(l[p]);var f=a;r()}([]);
We do not find any reference to the static folder which is generated as part of build. We checked the static folder and it does have the content of the functions that we are trying to export.
Can you help us with this query. And also can we configure the package in a way that it creates the final build such that entire bundled content comes in one file index.js.