обновление до webpack 4 из 3 - странная ошибка - PullRequest
0 голосов
/ 06 октября 2019

Обновление до веб-пакета 4.41 из веб-пакета 3.10 - большинство вещей работает, но когда я пытаюсь собрать dll, я получаю кучу ошибок, которые просто не имеют смысла для меня ...

> poisons-information-center@0.6.4 build:dll /home/vagrant/code/src
> node ./internals/scripts/dependencies.js

Building the Webpack DLL...
Hash: 1176a32e7fb63e23e452
Version: webpack 4.41.0
Time: 25008ms
Built at: 10/06/2019 4:05:10 AM
 1 asset
Entrypoint reactBoilerplateDeps = reactBoilerplateDeps.dll.js
chunk    {0} reactBoilerplateDeps.dll.js (reactBoilerplateDeps) 9.78 MiB [entry] [rendered]
   [33] (webpack)/buildin/global.js 472 bytes {0} [built]
   [82] (webpack)/buildin/module.js 497 bytes {0} [built]
 [1158] ../locale-data/index.js (ignored) 15 bytes {0} [built]
 [1182] dll reactBoilerplateDeps 12 bytes {0} [built]
 [1316] path (ignored) 15 bytes {0} [built]
 [1501] ./node_modules/regenerate-unicode-properties sync ^\.\/.*\.js$ 12.9 KiB {0} [built]
 [1954] util (ignored) 15 bytes {0} [built]
 [1956] util (ignored) 15 bytes {0} [built]
 [1978] crypto (ignored) 15 bytes {0} [built]
 [2472] ./locale-data/complete.js (ignored) 15 bytes {0} [built]
 [2474] ./node_modules/moment/locale sync ^\.\/.*$ 3 KiB {0} [built]
 [2736] (webpack)/buildin/amd-define.js 85 bytes {0} [built]
 [2737] (webpack)/buildin/amd-options.js 80 bytes {0} [built]
 [2925] (webpack)/buildin/harmony-module.js 573 bytes {0} [built]
     + 2946 hidden modules

ERROR in ./node_modules/core-js-compat/get-modules-list-for-target-version.js
Module not found: Error: Can't resolve './modules-by-versions' in '/home/vagrant/code/src/node_modules/core-js-compat'
 @ ./node_modules/core-js-compat/get-modules-list-for-target-version.js 3:26-58
 @ ./node_modules/@babel/preset-env/lib/polyfills/corejs3/usage-plugin.js
 @ ./node_modules/@babel/preset-env/lib/index.js
 @ dll reactBoilerplateDeps

ERROR in ./node_modules/@babel/preset-env/lib/normalize-options.js
Module not found: Error: Can't resolve 'core-js-compat/data' in '/home/vagrant/code/src/node_modules/@babel/preset-env/lib'
 @ ./node_modules/@babel/preset-env/lib/normalize-options.js 11:38-68
 @ ./node_modules/@babel/preset-env/lib/index.js
 @ dll reactBoilerplateDeps

ERROR in ./node_modules/@babel/preset-env/lib/polyfills/corejs3/entry-plugin.js
Module not found: Error: Can't resolve 'core-js-compat/data' in '/home/vagrant/code/src/node_modules/@babel/preset-env/lib/polyfills/corejs3'
 @ ./node_modules/@babel/preset-env/lib/polyfills/corejs3/entry-plugin.js 9:38-68
 @ ./node_modules/@babel/preset-env/lib/index.js
 @ dll reactBoilerplateDeps

ERROR in ./node_modules/@babel/preset-env/lib/polyfills/corejs3/usage-plugin.js
Module not found: Error: Can't resolve 'core-js-compat/data' in '/home/vagrant/code/src/node_modules/@babel/preset-env/lib/polyfills/corejs3'
 @ ./node_modules/@babel/preset-env/lib/polyfills/corejs3/usage-plugin.js 9:38-68
 @ ./node_modules/@babel/preset-env/lib/index.js
 @ dll reactBoilerplateDeps

ERROR in ./node_modules/@babel/preset-env/lib/polyfills/corejs3/entry-plugin.js
Module not found: Error: Can't resolve 'core-js-compat/entries' in '/home/vagrant/code/src/node_modules/@babel/preset-env/lib/polyfills/corejs3'
 @ ./node_modules/@babel/preset-env/lib/polyfills/corejs3/entry-plugin.js 19:38-71
 @ ./node_modules/@babel/preset-env/lib/index.js
 @ dll reactBoilerplateDeps
Done in 35.06s.

Babel плагины:

  "babel": {
    "presets": [
      [
        "@babel/preset-env",
        {
          "targets": {
            "browsers": "> 5%"
          },
          "useBuiltIns": "usage",
          "corejs": {
            "version": "3",
            "proposals": "true"
          }
        }
      ],
      "@babel/preset-react"
    ],
    "env": {
      "production": {
        "only": [
          "app"
        ],
        "plugins": [
          "transform-react-remove-prop-types",
          "@babel/plugin-transform-react-constant-elements",
          "@babel/plugin-transform-react-inline-elements",
          "@babel/plugin-proposal-class-properties"
        ]
      },
      "test": {
        "plugins": [
          "@babel/plugin-transform-es2015-modules-commonjs",
          "dynamic-import-node"
        ]
      }
    }
  },

и dependencies.js это

// No need to build the DLL in production
if (process.env.NODE_ENV === 'production') {
  process.exit(0);
}

require('shelljs/global');

const path = require('path');
const fs = require('fs');
const exists = fs.existsSync;
const writeFile = fs.writeFileSync;

const defaults = require('lodash/defaultsDeep');
const pkg = require(path.join(process.cwd(), 'package.json'));
const config = require('../config');
const dllConfig = defaults(pkg.dllPlugin, config.dllPlugin.defaults);
const outputPath = path.join(process.cwd(), dllConfig.path);
const dllManifestPath = path.join(outputPath, 'package.json');

/**
 * I use node_modules/react-boilerplate-dlls by default just because
 * it isn't going to be version controlled and babel wont try to parse it.
 */
mkdir('-p', outputPath);

echo('Building the Webpack DLL...');

/**
 * Create a manifest so npm install doesn't warn us
 */
if (!exists(dllManifestPath)) {
  writeFile(
    dllManifestPath,
    JSON.stringify(defaults({
      name: 'react-boilerplate-dlls',
      private: true,
      author: pkg.author,
      repository: pkg.repository,
      version: pkg.version,
    }), null, 2),
    'utf8'
  );
}

// the BUILDING_DLL env var is set to avoid confusing the development environment
exec('cross-env BUILDING_DLL=true webpack --display-chunks --color --config internals/webpack/webpack.dll.babel.js');

Я уверен, что это опечатка или что-то, что сейчас устарело в webpack4 ... но я могуне могу найти это ... любые более старые / более мудрые глаза и комментарии будут оценены

хорошо, я обнаружил, что, если я закомментировал раздел resol.extensions в конфигурации - все работало бы нормально ..

это похоже на ниже - я не уверен, почему это сработало, хотя

  resolve: {
    modules: ['app', 'node_modules'],
  //  extensions: [
   //   '.js',
  //    '.jsx',
  //    '.react.js',
  //  ],
    mainFields: [
      'browser',
      'jsnext:main',
      'main',
    ],
    alias: {
      moment$: 'moment/moment.js',
    },
  },
...