@zengenti/contensis-react-base 3.0.0-beta.69 → 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.
- package/cjs/contensis-react-base.js +86 -26
- package/cjs/contensis-react-base.js.map +1 -1
- package/esm/contensis-react-base.js +86 -26
- package/esm/contensis-react-base.js.map +1 -1
- package/models/server/util/bundles.d.ts +17 -21
- package/models/server/util/getVersionInfo.d.ts +1 -0
- package/package.json +2 -1
- package/CHANGELOG.md +0 -293
- package/package-lock.json +0 -12406
|
@@ -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
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
})
|
|
3806
|
-
|
|
3807
|
-
|
|
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
|
+
}
|
|
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;
|
|
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
|
|
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
|
-
|
|
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 ||
|
|
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}/`);
|
|
@@ -3884,6 +3933,17 @@ const addVarnishAuthenticationHeaders = (state, response, groups = {}) => {
|
|
|
3884
3933
|
}
|
|
3885
3934
|
};
|
|
3886
3935
|
|
|
3936
|
+
const getVersionInfo = staticFolderPath => {
|
|
3937
|
+
try {
|
|
3938
|
+
const versionData = fs__default["default"].readFileSync(`dist/${staticFolderPath}/version.json`, 'utf8');
|
|
3939
|
+
const versionInfo = JSON.parse(versionData);
|
|
3940
|
+
return versionInfo;
|
|
3941
|
+
} catch (ex) {
|
|
3942
|
+
console.error(`Unable to read from "version.json"`, ex);
|
|
3943
|
+
return {};
|
|
3944
|
+
}
|
|
3945
|
+
};
|
|
3946
|
+
|
|
3887
3947
|
const webApp = (app, ReactApp, config) => {
|
|
3888
3948
|
const {
|
|
3889
3949
|
stateType = 'immutable',
|
|
@@ -3905,7 +3965,7 @@ const webApp = (app, ReactApp, config) => {
|
|
|
3905
3965
|
const attributes = stringifyAttributes(scripts.attributes);
|
|
3906
3966
|
scripts.startup = scripts.startup || startupScriptFilename;
|
|
3907
3967
|
const responseHandler = typeof handleResponses === 'function' ? handleResponses : handleResponse;
|
|
3908
|
-
const versionInfo =
|
|
3968
|
+
const versionInfo = getVersionInfo(staticFolderPath);
|
|
3909
3969
|
app.get('/*', async (request, response) => {
|
|
3910
3970
|
const {
|
|
3911
3971
|
url
|
|
@@ -3955,7 +4015,7 @@ const webApp = (app, ReactApp, config) => {
|
|
|
3955
4015
|
store.dispatch(actions.setCurrentProject(project, groups, request.hostname));
|
|
3956
4016
|
const loadableExtractor = loadableChunkExtractors();
|
|
3957
4017
|
const jsx = /*#__PURE__*/React__default["default"].createElement(server.ChunkExtractorManager, {
|
|
3958
|
-
extractor: loadableExtractor
|
|
4018
|
+
extractor: loadableExtractor.commonLoadableExtractor
|
|
3959
4019
|
}, /*#__PURE__*/React__default["default"].createElement(reactCookie.CookiesProvider, {
|
|
3960
4020
|
cookies: cookies
|
|
3961
4021
|
}, /*#__PURE__*/React__default["default"].createElement(reactRedux.Provider, {
|
|
@@ -3968,9 +4028,9 @@ const webApp = (app, ReactApp, config) => {
|
|
|
3968
4028
|
withEvents: withEvents
|
|
3969
4029
|
})))));
|
|
3970
4030
|
const {
|
|
3971
|
-
templateHTML,
|
|
3972
|
-
templateHTMLFragment,
|
|
3973
|
-
templateHTMLStatic
|
|
4031
|
+
templateHTML = '',
|
|
4032
|
+
templateHTMLFragment = '',
|
|
4033
|
+
templateHTMLStatic = ''
|
|
3974
4034
|
} = bundleData.default.templates || bundleData.legacy.templates || {}; // Serve a blank HTML page with client scripts to load the app in the browser
|
|
3975
4035
|
|
|
3976
4036
|
if (accessMethod.DYNAMIC) {
|
|
@@ -3996,7 +4056,7 @@ const webApp = (app, ReactApp, config) => {
|
|
|
3996
4056
|
reactHelmet.Helmet.rewind();
|
|
3997
4057
|
const htmlAttributes = helmet.htmlAttributes.toString();
|
|
3998
4058
|
let title = helmet.title.toString();
|
|
3999
|
-
const metadata = helmet.meta.toString().concat(helmet.link.toString());
|
|
4059
|
+
const metadata = helmet.meta.toString().concat(helmet.base.toString()).concat(helmet.link.toString()).concat(helmet.script.toString()).concat(helmet.noscript.toString());
|
|
4000
4060
|
|
|
4001
4061
|
if (context.url) {
|
|
4002
4062
|
return response.redirect(302, context.url);
|