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

Not working "Why aren't files in node_modules being transformed?" #284

Open
mmmDanone opened this issue Apr 10, 2019 · 14 comments
Open

Not working "Why aren't files in node_modules being transformed?" #284

mmmDanone opened this issue Apr 10, 2019 · 14 comments

Comments

@mmmDanone
Copy link

mmmDanone commented Apr 10, 2019

Not working:
.transform(babelify, { global: true, ignore: [/\/node_modules\/(?!app\/)/] })

@jean-emmanuel
Copy link

jean-emmanuel commented May 23, 2019

This works for me: ignore: [/^(?!.*\/node_modules\/app\/)/]

@niftylettuce
Copy link

I can confirm that babelify does not globally transform node_modules if you specify { global: true }.

@builtbylane
Copy link

@niftylettuce I am seeing this too. I'm not able to transform any of the required node_modules. even when I set {global: true, ignore: undefined }

@niftylettuce
Copy link

@builtbylane I have a pretty cool solution/alternative that even has factor-bundle built-in. Will share soon. IMO there is a core bug somewhere here that nobody has figured out or dedicated time to. Obviously this is broken. The better solution is to run browserify and then babel separately.

@builtbylane
Copy link

@niftylettuce I was just starting to go down that same path but got sidetracked. Please share! 🥗

@niftylettuce
Copy link

I just have to push it up, need a little bit longer

@loganfsmyth
Copy link
Member

Assuming you're using Babel 7:
It is hard to say since this didn't specify how it is configuring things, but everything in https://babeljs.io/docs/en/config-files applies here. If you're using a .babelrc file, it is still package-scoped, even if you run the transform itself with global: true, so make sure you're using a babel.config.js,

@niftylettuce
Copy link

OK it's done. v0.2.9 of Lad has an updated gulp config that satisfies our needs here.

npm install -g lad

https://lad.js.org

https://github.com/ladjs/lad/blob/master/template/gulpfile.js#L181-L199

Happy hacking, and feel free to join our Slack @ https://slack.crocodilejs.com/

@builtbylane
Copy link

@loganfsmyth I've changed my config file to babel.config.js to no avail. Babelify still doesn't honor my settings for the node_modules

@TidyLuke
Copy link

I can't seem to get this to work at all. The global option no longer works, setting ignores in my gulpfile does not work, removing my config into babel.config.js or babel.config.json does not work. I'm stumped as to how I can transfom a package. Any help would be greatly appreciated.

@romain130492
Copy link

any news about this ?.......

@vielhuber
Copy link

vielhuber commented Apr 30, 2022

Does anybody know how the ignore pattern can be used inside npm scripts on the command line?

I have this in my npm scripts:

"js": "browserify script.js --outfile bundle.js -t [ babelify --global --ignore [ node_modules\/(?!swiper) ] ]",

Result:
Syntax error: "(" unexpected

"js": "browserify script.js --outfile bundle.js -t [ babelify --global --ignore [ node_modules\/\\(?!swiper\\) ] ]",

Result:
Doesn't work, since it does not properly ignore all packages except the defined ones.

@vielhuber
Copy link

Just found a clever way:

"js": "browserify script.js --outfile bundle.js -t [ babelify --global --only [ _js node_modules\/swiper ] ]",

You can define more packages to transform by adding them (space separated) to the array of only.

@Maxim-Mazurok
Copy link

Maxim-Mazurok commented Jun 16, 2022

Gentlemen, I believe we all have been deceived by Windows once again.
I've added some logging and noticed that we have \ instead of / in filename:

babelOpts: {
    ignore: [ /node_modules\/(?!whatwg-fetch)/ ],
    presets: [ [Array] ],
    assumptions: { arrayLikeIsIterable: true },
    sourceType: 'module',
    cwd: 'C:\\Users\\maxim\\browserify-temp',
    caller: { name: 'babelify' },
    filename: 'C:\\Users\\maxim\\browserify-temp\\node_modules\\core-js\\internals\\to-object.js',
    sourceFileName: undefined
  }

So the fix is to make it platform-independent:

ignore: [/[/\\]node_modules[/\\](?!whatwg-fetch[/\\])/],

Hope it helps!

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

9 participants