@zengenti/contensis-react-base 3.0.0-beta.70 → 3.0.0-beta.71

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3772,7 +3772,7 @@ const loadableBundleData = ({
3772
3772
  const bundle = {};
3773
3773
 
3774
3774
  try {
3775
- bundle.stats = JSON.parse(readFileSync(stats.replace('/target', build ? `/${build}` : '')));
3775
+ bundle.stats = stats ? JSON.parse(readFileSync(stats.replace('/target', build ? `/${build}` : ''))) : null;
3776
3776
  } catch (ex) {
3777
3777
  // console.info(ex);
3778
3778
  bundle.stats = null;
@@ -3792,31 +3792,51 @@ const loadableBundleData = ({
3792
3792
  return bundle;
3793
3793
  };
3794
3794
  const loadableChunkExtractors = () => {
3795
+ const commonLoadableExtractor = new server.ChunkExtractor({
3796
+ stats: {}
3797
+ });
3798
+
3795
3799
  try {
3796
- const modern = new server.ChunkExtractor({
3797
- entrypoints: ['app'],
3798
- namespace: 'modern',
3799
- statsFile: path__default["default"].resolve('dist/modern/loadable-stats.json')
3800
- });
3801
- const legacy = new server.ChunkExtractor({
3802
- entrypoints: ['app'],
3803
- namespace: 'legacy',
3804
- statsFile: path__default["default"].resolve('dist/legacy/loadable-stats.json')
3805
- });
3806
- const commonLoadableExtractor = {
3807
- addChunk(chunk) {
3808
- modern.addChunk(chunk);
3809
- if (typeof legacy.stats.assetsByChunkName[chunk] !== 'undefined') legacy.addChunk(chunk);
3810
- }
3800
+ let modern;
3801
+ let legacy;
3802
+
3803
+ try {
3804
+ modern = new server.ChunkExtractor({
3805
+ entrypoints: ['app'],
3806
+ namespace: 'modern',
3807
+ statsFile: path__default["default"].resolve('dist/modern/loadable-stats.json')
3808
+ });
3809
+ } catch (e) {
3810
+ console.info('@loadable/server modern ChunkExtractor not available');
3811
+ }
3812
+
3813
+ try {
3814
+ legacy = new server.ChunkExtractor({
3815
+ entrypoints: ['app'],
3816
+ namespace: 'legacy',
3817
+ statsFile: path__default["default"].resolve('dist/legacy/loadable-stats.json')
3818
+ });
3819
+ } catch (e) {
3820
+ console.info('@loadable/server legacy ChunkExtractor not available');
3821
+ }
3822
+
3823
+ commonLoadableExtractor.addChunk = chunk => {
3824
+ var _modern, _legacy, _legacy2;
3811
3825
 
3826
+ (_modern = modern) === null || _modern === void 0 ? void 0 : _modern.addChunk(chunk);
3827
+ if (typeof ((_legacy = legacy) === null || _legacy === void 0 ? void 0 : _legacy.stats.assetsByChunkName[chunk]) !== 'undefined') (_legacy2 = legacy) === null || _legacy2 === void 0 ? void 0 : _legacy2.addChunk(chunk);
3812
3828
  };
3829
+
3813
3830
  return {
3814
3831
  commonLoadableExtractor,
3815
3832
  modern,
3816
3833
  legacy
3817
3834
  };
3818
3835
  } catch (e) {
3819
- console.info('@loadable/server ChunkExtractor not available');
3836
+ console.info('@loadable/server no ChunkExtractor available');
3837
+ return {
3838
+ commonLoadableExtractor
3839
+ };
3820
3840
  }
3821
3841
  };
3822
3842
  const getBundleData = (config, staticRoutePath) => {
@@ -3827,17 +3847,46 @@ const getBundleData = (config, staticRoutePath) => {
3827
3847
  };
3828
3848
  if (!bundleData.default || bundleData.default === {}) bundleData.default = bundleData.legacy || bundleData.modern;
3829
3849
  return bundleData;
3830
- };
3850
+ }; // export const buildBundleTags = (
3851
+ // bundles,
3852
+ // differentialBundles = false,
3853
+ // staticRoutePath = 'static',
3854
+ // attributes = ''
3855
+ // ) => {
3856
+ // // Take the bundles returned from Loadable.Capture
3857
+ // const bundleTags = bundles
3858
+ // .filter(b => b)
3859
+ // .map(bundle => {
3860
+ // if (bundle.publicPath.includes('/modern/'))
3861
+ // return differentialBundles
3862
+ // ? `<script ${attributes} type="module" src="${replaceStaticPath(
3863
+ // bundle.publicPath,
3864
+ // staticRoutePath
3865
+ // )}"></script>`
3866
+ // : null;
3867
+ // return `<script ${attributes}${
3868
+ // differentialBundles ? ' nomodule' : ''
3869
+ // } src="${replaceStaticPath(
3870
+ // bundle.publicPath,
3871
+ // staticRoutePath
3872
+ // )}"></script>`;
3873
+ // })
3874
+ // .filter(f => f);
3875
+ // return bundleTags;
3876
+ // };
3877
+
3831
3878
  const getBundleTags = (loadableExtractor, scripts, staticRoutePath = 'static') => {
3832
3879
  let startupTag = ''; // Add the static startup script to the bundleTags
3833
3880
 
3834
3881
  if (scripts !== null && scripts !== void 0 && scripts.startup) startupTag = `<script ${stringifyAttributes(scripts.attributes)} src="/${staticRoutePath}/${scripts.startup}"></script>`; // Get the script tags from their respective extractor instances
3835
3882
 
3836
3883
  if (loadableExtractor) {
3837
- const legacyScriptTags = loadableExtractor === null || loadableExtractor === void 0 ? void 0 : loadableExtractor.legacy.getScriptTags({
3884
+ var _loadableExtractor$le, _loadableExtractor$mo;
3885
+
3886
+ const legacyScriptTags = (_loadableExtractor$le = loadableExtractor.legacy) === null || _loadableExtractor$le === void 0 ? void 0 : _loadableExtractor$le.getScriptTags({
3838
3887
  nomodule: 'nomodule'
3839
3888
  });
3840
- const modernScriptTags = loadableExtractor === null || loadableExtractor === void 0 ? void 0 : loadableExtractor.modern.getScriptTags({
3889
+ const modernScriptTags = (_loadableExtractor$mo = loadableExtractor.modern) === null || _loadableExtractor$mo === void 0 ? void 0 : _loadableExtractor$mo.getScriptTags({
3841
3890
  type: 'module'
3842
3891
  });
3843
3892
  const scriptTags = `${startupTag}${legacyScriptTags || ''}${modernScriptTags || ''}`.replace(/"\/static\//g, `"/${staticRoutePath}/`);
@@ -3966,7 +4015,7 @@ const webApp = (app, ReactApp, config) => {
3966
4015
  store.dispatch(actions.setCurrentProject(project, groups, request.hostname));
3967
4016
  const loadableExtractor = loadableChunkExtractors();
3968
4017
  const jsx = /*#__PURE__*/React__default["default"].createElement(server.ChunkExtractorManager, {
3969
- extractor: loadableExtractor === null || loadableExtractor === void 0 ? void 0 : loadableExtractor.commonLoadableExtractor
4018
+ extractor: loadableExtractor.commonLoadableExtractor
3970
4019
  }, /*#__PURE__*/React__default["default"].createElement(reactCookie.CookiesProvider, {
3971
4020
  cookies: cookies
3972
4021
  }, /*#__PURE__*/React__default["default"].createElement(reactRedux.Provider, {
@@ -3979,9 +4028,9 @@ const webApp = (app, ReactApp, config) => {
3979
4028
  withEvents: withEvents
3980
4029
  })))));
3981
4030
  const {
3982
- templateHTML,
3983
- templateHTMLFragment,
3984
- templateHTMLStatic
4031
+ templateHTML = '',
4032
+ templateHTMLFragment = '',
4033
+ templateHTMLStatic = ''
3985
4034
  } = bundleData.default.templates || bundleData.legacy.templates || {}; // Serve a blank HTML page with client scripts to load the app in the browser
3986
4035
 
3987
4036
  if (accessMethod.DYNAMIC) {