Skip to content
This repository has been archived by the owner on May 11, 2018. It is now read-only.

Trouble when updating from 1.4 to 1.5 #334

Closed
spoldman opened this issue May 22, 2017 · 17 comments
Closed

Trouble when updating from 1.4 to 1.5 #334

spoldman opened this issue May 22, 2017 · 17 comments

Comments

@spoldman
Copy link

I'm getting an error after update of this package. I did a bit of digging and it looks like _targetsParser2 i undefined in the built source.

Here is the stack trace

TypeError: Cannot read property 'default' of undefined (While processing preset: "C:\Code\Frontend\Cosmic\packages\mono-cli\node_modules\babel-preset-env\lib\index.js") (While processing preset: "C:\Code\Frontend\Cosmic\packages\mono-cli\node_modules\babel-preset-env\lib\index.js")
at buildPreset (C:\Code\Frontend\Cosmic\packages\mono-cli\node_modules\babel-preset-env\lib\index.js:148:36)
at C:\Code\Frontend\Cosmic\packages\mono-cli\node_modules\babel-core\lib\transformation\file\options\option-manager.js:317:46
at Array.map (native)
at OptionManager.resolvePresets (C:\Code\Frontend\Cosmic\packages\mono-cli\node_modules\babel-core\lib\transformation\file\options\option-manager.js:275:20)
at OptionManager.mergePresets (C:\Code\Frontend\Cosmic\packages\mono-cli\node_modules\babel-core\lib\transformation\file\options\option-manager.js:264:10)
at OptionManager.mergeOptions (C:\Code\Frontend\Cosmic\packages\mono-cli\node_modules\babel-core\lib\transformation\file\options\option-manager.js:249:14)
at OptionManager.init (C:\Code\Frontend\Cosmic\packages\mono-cli\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
at compile (C:\Code\Frontend\Cosmic\packages\mono-cli\node_modules\babel-register\lib\node.js:103:45)
at loader (C:\Code\Frontend\Cosmic\packages\mono-cli\node_modules\babel-register\lib\node.js:144:14)
at Object.require.extensions.(anonymous function) [as .js] (C:\Code\Frontend\Cosmic\packages\mono-cli\node_modules\babel-register\lib\node.js:154:7)

@hzoo
Copy link
Member

hzoo commented May 22, 2017

Are you using 1.5 or 1.5.1?

@spoldman
Copy link
Author

Both 1.5 and 1.5.1 give me this error

@hzoo
Copy link
Member

hzoo commented May 22, 2017

Can you provide more information? Config etc

@spoldman
Copy link
Author

spoldman commented May 22, 2017

Sure, I'm using it like this in my code.

require('babel-register')({ babelrc: false, ignore: false, only: /src/, presets: [ ['env', { node: 'current' }] ], plugins: [ 'transform-export-extensions', 'add-module-exports', 'transform-runtime', 'syntax-object-rest-spread', 'transform-object-rest-spread' ] })

@spoldman
Copy link
Author

Using node 7.1

@spoldman
Copy link
Author

Updated to node 7.10 and the error still occurs.

@loganfsmyth
Copy link
Member

loganfsmyth commented May 22, 2017

Your usage of ignore: false is causing your issue. If you want to compile things in node_modules you should have a whitelist of the modules you actually want to compile, otherwise you're doing tons of extra work. e.g.

ignore: /node_modules\/(?!some-module|another_module|third_module)/

to compile just those modules.

This issue was caused because of the changes in #324 because that babel key in the package.json is published to npm, so anyone using ignore: false will be telling babel-preset-env to compile itself, hence the circular dependency failure in your error.

I'll leave it up to others as to whether this is worth changing. ignore: false is never a good idea in the current architecture. We've talked about changing the behavior of file-based configs in 7.x which would fix this, but we haven't settled on anything yet.

@spoldman
Copy link
Author

I removed the ignore options, reinstalled the package and I had no success. Still having the same error using v1.5

@existentialism
Copy link
Member

@spoldman any chance you could put up a small repo that reproduces the problem?

@tomatau
Copy link

tomatau commented Jun 23, 2017

I have the same problem, I need to include some node_modules because of the infrastructure at work.

So our entry looks like this:

require('babel-polyfill')
require('babel-register')({
  only: [
    /src/,
    /nowtv-web-toolkit/,
    /nowtv-assurance-shared/,
  ],
})
require('./server-start')

This should be still using the default of ignore: /node_modules/ though so I don't get why it would be attempting to compile the babel-preset-env lib...

.babelrc:

{
  "presets": [
    ["env", { "targets": { "node": true } }],
    "react"
  ],

We run similar options through webpack when bundling and it works fine, this just breaks on our server side render logic.

@spoldman
Copy link
Author

spoldman commented Aug 4, 2017

I'm still having this issue trying to update, version 1.6 still has the same problem for me. I had some time to create a repository to replicate this issue hope that helps solving the issue.

It can be found here: https://github.com/spoldman/Update-issue-with-babel-preset-env

@existentialism
Copy link
Member

@spoldman thanks for creating the repo! Just to be clear, you said this worked with babel-preset-env@1.4.0? I'm getting the same error with that version.

@spoldman
Copy link
Author

spoldman commented Aug 8, 2017

I double checked and yes, it works using version 1.4.

image

@existentialism
Copy link
Member

@spoldman can you try changing your only to only: /\.\/src/?

@yavorsky and I were digging into this... and it looks like in browserslist 2.x (which we bumped in 1.4 -> 1.5), they switched to using caniusedb-lite, which contains a module named iframe-srcdoc... and due to some fun gotchas/bugs with only (which should be fixed in 7.0), it caused things to fail silently.

@spoldman
Copy link
Author

spoldman commented Aug 9, 2017

@existentialism Looks like this works. What changed to cause this?

@existentialism
Copy link
Member

Combination of us upgrading to browserslist 2.0 during 1.4 -> 1.5, which happened to expose one (of many) bugs with using "only" and babel-register, have you tried using Babel 7 at all? We hope many of the issues there have been resolved, and if not, we should definitely get it taken care of!

Thanks again for the cooperation and patience!

@spoldman
Copy link
Author

spoldman commented Aug 9, 2017

I will look into updating to babel 7. Thanks for the help.

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

No branches or pull requests

5 participants