Skip to content
This repository has been archived by the owner on Nov 30, 2021. It is now read-only.

fix(exports): fix export for webpack (commonjs) #206

Closed
wants to merge 2 commits into from

Conversation

aaronroberson
Copy link

I read the contributing document. . .

Here is my webpack.config.js file if it helps:

{
    entry: {
      app: './src/app.js'
    },
    output: {
      filename: 'app.js'
    },
    watch: watch,
    devtool: (process.env.NODE_ENV === 'production') ? 'source-map' : 'inline-source-map',
    module: {
      preLoaders: [{test: /\.js$/, exclude: [/node_modules/, /bower_components/], loader: 'jshint'}],
      loaders: [
        {test: /\.js$/, exclude: [/node_modules/, /bower_components/], loader: 'babel', query: {
          // https://github.com/babel/babel-loader#options
          cacheDirectory: true,
          presets: ['es2015', 'stage-0', 'stage-1', 'stage-2'],
          plugins: ['transform-es2015-modules-commonjs']
        }},
        {test: /\.css$/, loader: 'style!css!postcss'},
        {test: /\.json$/, exclude: [/node_modules/, /bower_components/], loader: 'json'},
        {test: /[\/]angular\.js$/, exclude: [/bower_components/], loader: 'exports?angular'}
      ]
    },
    postcss: [autoprefixer({ browsers: ['last 2 version'] })],
    plugins: [
      new BowerWebpackPlugin({
        exclude: [
          /.*angular*/,
          /.*angular-cookies*/,
          /.*angular-sanitize*/,
          /.*angular-resource*/,
          /.*angular-messages*/,
          /.*angular-translate*/,
          /.*angular-touch*/,
          /.*angular-mocks*/,
          /.*jquery*/,
          /.*bootstrap-sass-official\/.*\.js/,
          /.*bootstrap\.css/,
          /.*awesome-bootstrap-checkbox*/,
          /.*font-awesome*/,
          /.*\.less/
        ],
        searchResolveModulesDirectories: false
      }),
      new webpack.ProvidePlugin({
        $: 'jquery',
        jQuery: 'jquery',
        'window.jQuery': 'jquery',
        moment: 'moment'
      }),
      new webpack.DefinePlugin({
        ENV_TEST: (JSON.stringify(process.env.NODE_ENV) === 'test') ? true : false
      }),
      new webpack.DefinePlugin({
        APP_VERSION: JSON.stringify(require('./package.json').version)
      })
    ],
    resolve: {
      root: path.resolve('./src'),
      modulesDirectories: ['node_modules'],
      extensions: ['', '.js', '.json', '.css']
    }
  };

Resolves #108

Here is my webpack.config.js file if it helps:

```
{
    entry: {
      app: './src/app.js'
    },
    output: {
      filename: 'app.js'
    },
    watch: watch,
    devtool: (process.env.NODE_ENV === 'production') ? 'source-map' : 'inline-source-map',
    module: {
      preLoaders: [{test: /\.js$/, exclude: [/node_modules/, /bower_components/], loader: 'jshint'}],
      loaders: [
        {test: /\.js$/, exclude: [/node_modules/, /bower_components/], loader: 'babel', query: {
          // https://github.com/babel/babel-loader#options
          cacheDirectory: true,
          presets: ['es2015', 'stage-0', 'stage-1', 'stage-2'],
          plugins: ['transform-es2015-modules-commonjs']
        }},
        {test: /\.css$/, loader: 'style!css!postcss'},
        {test: /\.json$/, exclude: [/node_modules/, /bower_components/], loader: 'json'},
        {test: /[\/]angular\.js$/, exclude: [/bower_components/], loader: 'exports?angular'}
      ]
    },
    postcss: [autoprefixer({ browsers: ['last 2 version'] })],
    plugins: [
      new BowerWebpackPlugin({
        exclude: [
          /.*angular*/,
          /.*angular-cookies*/,
          /.*angular-sanitize*/,
          /.*angular-resource*/,
          /.*angular-messages*/,
          /.*angular-translate*/,
          /.*angular-touch*/,
          /.*angular-mocks*/,
          /.*jquery*/,
          /.*bootstrap-sass-official\/.*\.js/,
          /.*bootstrap\.css/,
          /.*awesome-bootstrap-checkbox*/,
          /.*font-awesome*/,
          /.*\.less/
        ],
        searchResolveModulesDirectories: false
      }),
      new webpack.ProvidePlugin({
        $: 'jquery',
        jQuery: 'jquery',
        'window.jQuery': 'jquery',
        moment: 'moment'
      }),
      new webpack.DefinePlugin({
        ENV_TEST: (JSON.stringify(process.env.NODE_ENV) === 'test') ? true : false
      }),
      new webpack.DefinePlugin({
        APP_VERSION: JSON.stringify(require('./package.json').version)
      })
    ],
    resolve: {
      root: path.resolve('./src'),
      modulesDirectories: ['node_modules'],
      extensions: ['', '.js', '.json', '.css']
    }
  };
```

Resolves urish#108
Fix the module export for webpack

Resolves urish#108
@urish
Copy link
Owner

urish commented Nov 20, 2015

Thanks, I will look into that in a few days, so we will have it ready for the next beta release

@aaronroberson
Copy link
Author

Ok I will add the forked version to my project in the time being. Thanks

@Turanchoks
Copy link

Hi! Any plans on getting this merged?

@urish
Copy link
Owner

urish commented Mar 1, 2016

There is a plan to have a working solution for webpack, but we have to made sure it doesn't break other use cases (browserify, require.js, system.js, etc)

@urish
Copy link
Owner

urish commented Oct 6, 2016

Thanks for your time!

This is partially resolved by commit 919882e (see #261), and seems like it doesn't work for all users anyway (see #253), so closing.

@urish urish closed this Oct 6, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cannot use angular-moment under webpack
3 participants