question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Dependency issue with babel-runtime

See original GitHub issue

Is this a bug report?

Yes.

Environment

npm ls dynamic-cdn-webpack-plugin

gravitify.io@1.0.0 /home/shukant/gravitify.io
└── dynamic-cdn-webpack-plugin@4.0.0 


npm ls webpack

gravitify.io@1.0.0 /home/shukant/gravitify.io
└── webpack@4.29.6 

Steps to Reproduce

My webpack.config.js file looks exactly like this:

const path = require('path');
const webpack = require('webpack');

const DynamicCdnWebpackPlugin = require('dynamic-cdn-webpack-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const TerserPlugin = require('terser-webpack-plugin');

module.exports = {
  mode: "production",
  entry: "./src/index.js",
  output: {
    path: path.resolve(__dirname, "dist"),
    filename: "main.js"
  },
  module: {
    rules: [
      {
        test: /\.m?js$/,
        exclude: [path.join(__dirname, '/node_modules/')],
        use: {
          loader: 'babel-loader',
          options: {
            presets: [`@babel/preset-env`],
            plugins: [
              "@babel/plugin-minify-dead-code-elimination",
              "@babel/plugin-transform-object-set-prototype-of-to-assign"
            ]
          }
        }
      }
    ]
  },
  plugins: [
    new DynamicCdnWebpackPlugin(),
    new HtmlWebpackPlugin(),
    new webpack.ProgressPlugin()
  ],
  optimization: {
    minimizer: [
      new TerserPlugin({
        cache: true,
        parallel: true,
        terserOptions: {
          mangle: true
        }
      })
    ]
  }
}

(Write your steps here:)

  1. I just run webpack --optimize-minimize

Expected Behavior

It should build fine.

Actual Behavior

Logs error:

/home/shukant/gravitify.io/node_modules/webpack-cli/bin/cli.js:231
				throw err;
				^

Error: Cannot find module 'babel-runtime/core-js/object/values'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (/home/shukant/gravitify.io/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/home/shukant/gravitify.io/node_modules/dynamic-cdn-webpack-plugin/lib/index.js:7:15)
    at Module._compile (/home/shukant/gravitify.io/node_modules/v8-compile-cache/v8-compile-cache.js:178:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (/home/shukant/gravitify.io/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/home/shukant/gravitify.io/node_modules/dynamic-cdn-webpack-plugin/index.js:2:18)
    at Module._compile (/home/shukant/gravitify.io/node_modules/v8-compile-cache/v8-compile-cache.js:178:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (/home/shukant/gravitify.io/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/home/shukant/gravitify.io/webpack.config.js:4:33)
    at Module._compile (/home/shukant/gravitify.io/node_modules/v8-compile-cache/v8-compile-cache.js:178:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (/home/shukant/gravitify.io/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at WEBPACK_OPTIONS (/home/shukant/gravitify.io/node_modules/webpack-cli/bin/convert-argv.js:115:13)
    at requireConfig (/home/shukant/gravitify.io/node_modules/webpack-cli/bin/convert-argv.js:117:6)

Reproducible Demo

(Paste the link to an example project and exact instructions to reproduce the issue.)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
NReilinghcommented, Apr 4, 2019

I think I figured this out. This package has a dev dependency on babel-plugin-transform-runtime, and is configured to use it in ('package.json').babel.plugins.

According to the docs for @babel/plugin-transform-runtime, using this plugin requires adding @babel/runtime as a production dependency, which was removed from this project in 124e6f9c87adf404e12009e6396d2e145aaf790d.

I tried re-building this project in a fork without using the plugin and dev dependency, and everything still appears to build and test just fine. I’ll submit a pull request with the change. The purpose of babel-runtime is to reduce compiled artifact size by including shared babel shims in a module instead of duplicating those shims in the compiled output, and while it does reduce the size of index.js from 9,035 bytes to 8,845 bytes, it does so at the expense of 48 KB for babel-runtime itself.

0reactions
ShukantPalcommented, Mar 30, 2019

However, shouldn’t babel-transform-runtime be deprecated. I use the @babel/ plugins and tried installing @babel/plugin-transform-runtime package instead. That does not resolve the issue. I think you need to fix it, as newer Babel isn’t gonna support your solution @NReilingh

Read more comments on GitHub >

github_iconTop Results From Across the Web

[Question] How to handle @babel/runtime #1017 - GitHub
The issue I am having is how @babel/plugin-transform-runtime inserts ... Having a dependency execute @babel/register , and then execute one ...
Read more >
@babel/runtime is a true dependency | /*code-comments*/
I've been working on nom, a CLI designed to manage a directory of notes. It's written in Typescript, but I use Babel to...
Read more >
babel/runtime
babel /runtime` is a library that contains Babel modular runtime helpers. ... This is meant to be used as a runtime dependency along...
Read more >
Module not found: Can't resolve @babel/runtime/helpers
The @babel/runtime module should NOT be globally installed or be in your project's devDependencies , it should be in the dependencies object in...
Read more >
Do @babel/runtime / @babel/plugin-transform-runtime in CLI ...
I have recently added @babel/runtime as a dependency to the app (it was a silent dependency before, needed for other packages, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found