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.

autoloader config inverted?

See original GitHub issue

In docs of ProvidePlugin (https://webpack.js.org/guides/shimming/#provideplugin or https://webpack.github.io/docs/shimming-modules.html#plugin-provideplugin) config schema is:

{
   varName: 'module-name',
   $: 'jquery',
   window.jQuery: 'jquery'
}

In mix docs (https://github.com/JeffreyWay/laravel-mix/blob/master/docs/autoloading.md) it is inverted. And I can’t understand by viewing the code, why and where is this changed?

The problem with “inverted” syntax that it makes impossible to autoload modules, that don’t support old require() and only support ES6 imports. ProvidePlugin uses require() so you get {default: module} in your variable.

This is solved by this PR: https://github.com/webpack/webpack/pull/3597 and is mentioned in docs. So syntax for ES6 modules should be:

{
   autobind: ['class-autobind', 'default']
}

But this is not working with mix. Any ideas how to handle this?

Issue Analytics

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

github_iconTop GitHub Comments

2reactions
barryvdhcommented, Aug 19, 2017

For a (more popuplare) example, Bootstrap 4 needs this for Popper: https://getbootstrap.com/docs/4.0/getting-started/webpack/

    new webpack.ProvidePlugin({
        $: 'jquery',
        jQuery: 'jquery',
        'window.jQuery': 'jquery',
        Popper: ['popper.js', 'default'],
        // In case you imported plugins individually, you must also require them here:
        Util: "exports-loader?Util!bootstrap/js/dist/util",
        Dropdown: "exports-loader?Dropdown!bootstrap/js/dist/dropdown",
        ...
      })

So there is currently now way around this, other then using the ProvidePlugin directly? Not sure if this will be necesarry in the future, but otherwise when Laravel ships with Bootstrap 4, might be annoying?

2reactions
QWp6tcommented, Apr 14, 2017

It was reversed by mix mostly for cosmetic reasons.

{
  jquery: ['$', 'window.jQuery']
}

// vs

{
  '$': 'jquery',
  'window.jQuery': 'jquery'
}

The first one looks cleaner.

The implementation in mix completely overlooked situations like yours, however. So this is a legit bug.

As a workaround for now you can use mix.webpackConfig().

Example:

mix.webpackConfig({
  plugins: [
    new require('webpack').ProvidePlugin({
      __assign: ['tslib', '__assign'],
      __extends: ['tslib', '__extends'],
    })
  ]
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

Using and Abusing Auto Loader's Inferred Schema
Solution. Schema inference in Auto Loader works by sampling the data. It will do this by either reading 50GB or 1,000 files it...
Read more >
Databricks Autoloader: Data Ingestion Simplified 101 - Learn
This article provides a complete guide to effectively use Databricks Autoloader to simplify your Data Ingestion process for your business.
Read more >
What is Auto Loader? | Databricks on AWS
Auto Loader incrementally and efficiently processes new data files as they arrive in cloud storage without any additional setup.
Read more >
COMPOSER_DEV_MODE value is inverted in composer v2
According https://getcomposer.org/doc/articles/scripts.md : "During a composer install or update process, a variable named COMPOSER_DEV_MODE ...
Read more >
Configuration reference - Klipper documentation
Klipper uses the hardware names for these pins - for example PA4 . Pin names may be preceded by ! to indicate that...
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