Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude is not working #348

Open
tandrewnichols opened this issue Aug 18, 2015 · 6 comments
Open

Exclude is not working #348

tandrewnichols opened this issue Aug 18, 2015 · 6 comments

Comments

@tandrewnichols
Copy link

I know there have been other issues to this effect that have been resolved, so it's possible I'm doing this wrong. I want to set up two different bundles, one that includes lodash and one that is a standalone for people who have lodash included in their client scripts already. It looks like the right option is exclude (although I've also tried ignore), but I can't get grunt-browserify to leave out lodash. Here's my configuration for the two different bundles:

grunt.initConfig({
  browserify: {
    dist: {
      files: {
        'dist/feature-toggle-lib.js': 'dist/request-decoration.js'
      },
      options: {
        browserifyOptions: {
          standalone: 'FtoggleRequestDecoration'
        }
      }
    },
    standalone: {
      files: {
        'dist/feature-toggle-lib-standalone.js': 'dist/request-decoration.js'
      },
      options: {
        exclude: 'lodash',
        browserifyOptions: {
          standalone: 'FtoggleRequestDecoration'
        }
      }
    }
  }
});

As I mentioned, I've also tried replacing exclude with ignore and I've tried putting both inside browserifyOptions, and in all cases, lodash is still included in the build. Incidentally, when I do this directly with browserify, it works fine: browserify dist/request-decoration.js --exclude lodash --standalone FtoggleRequestDecoration > dist/feature-toggle-lib-standalone.js.

I know you'll ask what version I'm using; I updated to the most recent (^4.0.0) when this wasn't working, and that did not fix it.

@RaederDev
Copy link

I just had the same problem and figured it out.
You can get exclude to work by specifying the excludes as an Array like so:

options: {
    exclude: ['nw.gui']
}

@tandrewnichols
Copy link
Author

Interesting. I'll give that a try. Thanks!

@tleunen
Copy link
Collaborator

tleunen commented Oct 24, 2015

Yep, a lot of options require to be an array. We should probably also allow a single entry and convert it to an array when needed.

@ekkis
Copy link

ekkis commented Feb 12, 2016

I'm running grunt-browserify v4.0.1, grunt v0.4.5 and browserify v12.0.1 and have this problem too... I have a directory with all my source, which I browserify like this:

 14         browserify: {
 15             libs: {
 16                 src: ['src/*.js'],
 17                 dest: 'dist/libs.js'
 18             },  

and everything is fine, except that when I drop an index.js in the directory, which I need to exclude from browserification, I can't get the module to exclude it. I know it's not being excluded because the presence of that file generates the error:

Running "browserify:libs" (browserify) task

Error: Cannot find module './package.json' from '/Users/ekkis/Development/xxx/src'
Warning: Error running grunt-browserify. Use --force to continue.

here's what I currently have:

 14         browserify: {
 15             libs: {
 16                 src: ['src/*.js'],
 17                 dest: 'dist/libs.js',
 18                 options: {
 19                     exclude: ['index.js']
 20                 }
 21             },  

but like others, I've tried

ignore: `index.js'
exclude: 'index'
exclude: ['index'] 
exclude: 'index.js'
exclude: ['index.js'] 
exclude: 'src/index.js'
exclude: ['src/index.js'] 

all which fail in the same manner. curiously, the last attempt generates a different error:

Fatal error: cb is not a function

what am I doing wrong?

@0815fox
Copy link

0815fox commented Mar 9, 2016

I can confirm, that this issue also occurs with ignore. Also tired several ways, like @ekkis , nothing helped.

0815fox pushed a commit to 0815fox/grunt-browserify that referenced this issue Mar 9, 2016
@0815fox
Copy link

0815fox commented Mar 9, 2016

My fix above was wrong, it is a side effect.
I just came across browserify/browserify#1433 and now tried a relative path:

ignore: ['./build/**/XYZ.js']

This may also work with exclude?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants