Questions tagged [imports-loader]

16 questions
4
votes
0 answers

webpack - imports-loader vs ProvidePlugin

Could someone please show me the differences between the two? I know that the imports-loader will insert a require into the asking module and the ProvidePlugin will make an instance of, say Jquery, if the symbol $ is matched. But apart from that are…
3
votes
1 answer

Cannot find module issue with imports-loader when testing with Jest

When I am testing React components using Jest, I get following error for those components using imports-loader. Cannot find module 'imports-loader?jQuery=jquery!bootstrap/js/tooltip' Does anyone know how to fix this?
sam
  • 2,780
  • 1
  • 17
  • 30
2
votes
1 answer

Using Imports-Loader and Exports-Loader at same time for legacy code

I have 2 legacy JS files, which I do not want to change. For that reason I want to use exports-loader and imports-loader File B-legacy needs the global var GLOB from File A-legacy My webpack.config.js results in rules: [ { test: /\.ts$/,…
Daniel R
  • 1,122
  • 8
  • 16
2
votes
1 answer

webpack - imports-loader and ProvidePlugin: similar but not the same?

Here is what I have: a.js $(() => { $.x = 42; console.log('hello from a'); }); b.js $(() => { console.log($.x); console.log('hello from b'); }); index.html
Glenn Mohammad
  • 3,871
  • 4
  • 36
  • 45
2
votes
0 answers

Webpack imports-loader with coffeescript

I've a legacy application written in coffeescript and want to use webpack to bundle the project. The goal is to use webpack without impacting the current code. I've global functions in file functions.coffee that is used all over the application. Now…
Faalsh
  • 128
  • 2
  • 8
2
votes
1 answer

exports=>false in imports-loader in Webpack

If I use imports-loader, what does it mean exports=>false part in configuration? It should inject variable var exports = false, but I don't know when and why I need this variable. module : { loaders : [ { test :…
Matt
  • 8,195
  • 31
  • 115
  • 225
1
vote
1 answer

Using jQuery datatables with webpack - Error on new imports-loader version

I am using the latest datatables.net-bs version in a webpack setup (v1.11.5). To make it work, I had to set the following configuration in my webpack.config.js: { test: /datatables\.net.*/, use: 'imports-loader?define=>false' } I am using…
Ron
  • 22,128
  • 31
  • 108
  • 206
1
vote
1 answer

How to add modules in test for imports-loader configuration

As I am converting legacy webapp to webpack based application, it uses mCustomScrollbar. As per documentation of mCustomScrollbar, to run with webpack need to use imports-loader. But syntax given in doc is compatible with older version of webpack,…
Sheel
  • 1,010
  • 1
  • 17
  • 30
1
vote
1 answer

how does webpack process this module shimming pattern?

webpack's documentation lists an interesting pattern for shimming a module that sets properties on window, like window.XModule =…
Hristo
  • 45,559
  • 65
  • 163
  • 230
0
votes
0 answers

Getting error when upgrading webpack to 5.75.0 (latest)

When I tried to upgrade imports-loader to latest I am getting error as this.getOptions is not a function so i upgraded web pack from 4.29.6 to 5.75.0 and now I am getting below error: **[webpack-cli] TypeError: webpack.optimize.OccurrenceOrderPlugin…
0
votes
0 answers

How to convert inline imports-loader to configuration imports-loader?

I'm attempting to introduce webpack for a legacy SPA. I'm in a very similar position to the author of this article, where I've adapted their code to webpack v4. The application needs myApp defined globally, so I've exposed myApp like…
Khei
  • 73
  • 3
  • 11
0
votes
1 answer

Meteor Wonky Magic imports

I've been using meteor for a little while now, and am running into an unexpected behavior I've got my file system set up like: -workspace -client -server -shared -shared.js Inside of shared.js I create my mongo…
Spencer Cornwall
  • 289
  • 2
  • 14
0
votes
2 answers

Can I use webpack imports-loader to require CSS files alongside certain JS dependencies? (or, how to implicitly load CSS)

I'm trying to convert a large project using RequireJS to Webpack 4. The end goal is to be able to use both tools side by side, at least for development, with minimal changes to actual code required. I'm running into an issue with converting shim…
pilif
  • 31
  • 3
0
votes
1 answer

ERROR in jQuery is not defined webpack and imports-loader

I got this error when I tried to add a jquery library. { test: require("path").resolve("./main/static/src/application.js"), loader: 'imports-loader?this=>window,$=jquery!./main/static/src/vendor/jquery-ui/ui/widgets/draggable.js' } new…
0
votes
0 answers

Define is not a function with babel-polyfill and webpack on Azure

I'm having an issue when deploying a React/Redux site to Azure App Service. It builds and deploys fine, but when visiting the site I get JS errors for babel-polyfill - Uncaught TypeError: define is not a function. We're using webpack with a few…
Dave C
  • 457
  • 3
  • 10
1
2