fgnass / spin.js

A spinning activity indicator
http://spin.js.org
MIT License
9.3k stars 1.02k forks source link

problem with webpack #323

Closed phra closed 6 years ago

phra commented 8 years ago

hi,

webpack was failing bundling the code due to spin.js package name. to resolve i had to declare an alias section in webpack.config.js

config.resolve = {
    alias: {
      'spin': 'spin.js'
    }
  };

cheers.

fgnass commented 8 years ago

Can you post your complete webpack config? This shouldn't be an issue if node_modules is excluded.

phra commented 8 years ago

hi,

it's basically a copy of this one. i'm a maintainer of that starter kit.

thanks for your time.

fgnass commented 8 years ago

Cool, thanks! Do you use spin.js from npm or do you have a copy of spin.js in your app? And what error message do you get from webpack?

phra commented 8 years ago

it's not finding the module because spin.js triggers the regex: (or at least i think because aliases solved the problem)

loaders: [{
      // JS LOADER
      // Reference: https://github.com/babel/babel-loader
      // Transpile .js files using babel-loader
      // Compiles ES6 and ES7 into ES5 code
      test: /\.js$/,
      loader: 'babel',
      exclude: /node_modules/
    }
fgnass commented 8 years ago

Strange. If spin.js is installed via npm the exclude pattern should match (since spin.js will then be located under the node_modules folder) and the loader should be skipped.

phra commented 8 years ago

it doesn't find spin.js beacuse it's stripping the .js and looking for a spin module instead. my alias restores the intended behavior.

fgnass commented 8 years ago

I just cloned the angular-webpack repo, did a npm i -S spin.js, added import spin from 'spin.js'; to the app.js file and run npm run build without any errors. Could you provide a recipe to reproduce the error?

phra commented 8 years ago

really strange. i will look into it.. thanks for the feedback.

moravcik commented 7 years ago

I have a related problem with angular-spinner which depends on spin.js. My app is using webpack and it seems webpack uses AMD as standard module specification. The angular-spinner AMD definition is:

define(['angular', 'spin'], factory);

So the webpack is looking for module spin, instead of spin.js. The workaround from @phra helped to make it working. This might be the problem of angular-spiner rather than spin.js, just to note that.

phra commented 7 years ago

me too i'm using angular-spinner. let's open a ticket to them and reference it here.