sulu

Can not build admin CMS due to core.js issue


We recently upgraded to sulu cms 2.4.20 (I know, it is outdated) and are trying to manually build the admin js.

Unfortunatly we get the following very persistent errors connected to the jsrouting-bundle:

Build administration interface assets
-------------------------------------


> sulu-skeleton@ build /assets/admin
> webpack --mode production

   1406 modules

WARNING in ./node_modules/sulu-admin-bundle/services/ResourceRequester/registries/resourceRouteRegistry.js 28:4-18
"export 'default' (imported as 'symfonyRouting') was not found in 'fos-jsrouting/router'

WARNING in ./node_modules/sulu-admin-bundle/services/ResourceRequester/registries/resourceRouteRegistry.js 41:11-25
"export 'default' (imported as 'symfonyRouting') was not found in 'fos-jsrouting/router'

WARNING in ./node_modules/sulu-admin-bundle/services/ResourceRequester/registries/resourceRouteRegistry.js 51:11-25
"export 'default' (imported as 'symfonyRouting') was not found in 'fos-jsrouting/router'

WARNING in ./node_modules/sulu-media-bundle/containers/ImageMap/ImageRenderer.js 97:11-25
"export 'default' (imported as 'symfonyRouting') was not found in 'fos-jsrouting/router'

WARNING in ./node_modules/sulu-admin-bundle/stores/metadataStore/metadataStore.js 27:18-32
"export 'default' (imported as 'symfonyRouting') was not found in 'fos-jsrouting/router'

WARNING in ./node_modules/sulu-admin-bundle/containers/Badge/stores/BadgeStore.js 88:11-25
"export 'default' (imported as 'symfonyRouting') was not found in 'fos-jsrouting/router'

WARNING in ./node_modules/sulu-admin-bundle/views/List/toolbarActions/UploadToolbarAction.js 154:11-25
"export 'default' (imported as 'symfonyRouting') was not found in 'fos-jsrouting/router'

ERROR in /vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js/router.js
Module not found: Error: Can't resolve 'core-js/modules/es.array.push.js' in '/Users/andreas/Workdata/DWBN-IT/sulu/sulu/vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js'

ERROR in /vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js/router.js
Module not found: Error: Can't resolve 'core-js/modules/esnext.iterator.constructor.js' in '/Users/andreas/Workdata/DWBN-IT/sulu/sulu/vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js'

ERROR in /vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js/router.js
Module not found: Error: Can't resolve 'core-js/modules/esnext.iterator.for-each.js' in '/Users/andreas/Workdata/DWBN-IT/sulu/sulu/vendor/friendsofsymfony/jsrouting-bundle/Resources/public/js'

[ERROR] Unexpected error while building administration interface assets. 

I tried already everything in https://docs.sulu.io/en/2.4/cookbook/build-admin-frontend.html#common-errors, but the error persists.

Context:

node: v14.21.3
npm: 6.14.18
core-js: 3.39.0 (downgrading it to 3.18.0 as per babel.config.json does not solve the issue)

Any help with this would be greatly appreciated.


Solution

  • I've just added PR which should fix the issue: https://github.com/sulu/sulu/pull/7639

    Problem is in babel loading, as @Alexander Schranz suggested.

    In the meantime, until PR get's merged, you can also modify your local webpack.config.js inside admin assets folder and rebuild admin (don't replace your local webpack.config.js when prompted):

    /* eslint-disable flowtype/require-valid-file-annotation */
    /* eslint-disable import/no-nodejs-modules*/
    /* eslint-disable no-undef */
    const path = require('path');
    const webpackConfig = require('../../vendor/sulu/sulu/webpack.config.js');
    
    module.exports = (env, argv) => {
        env = env ? env : {};
        argv = argv ? argv : {};
    
        env.project_root_path = path.resolve(__dirname, '..', '..');
        env.node_modules_path = path.resolve(__dirname, 'node_modules');
    
        const config = webpackConfig(env, argv);
        config.entry = path.resolve(__dirname, 'index.js');
    
        config.module.rules = config.module.rules.map((rule) => {
            if (rule?.use?.loader === 'babel-loader') {
                let exclude = [rule.exclude, /friendsofsymfony\/jsrouting-bundle/];
                rule.exclude = exclude;
            }
            return rule;
        });
    
        return config;
    };