jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.26k stars 508 forks source link

.browserslistrc being ignored from @babel/preset-env #655

Closed kylemh closed 4 years ago

kylemh commented 4 years ago

Current Behavior

I have a custom babel config:

{
  "presets": ["@babel/preset-env", "@babel/react", "@babel/typescript"],
  "plugins": ["@babel/plugin-transform-react-display-name", "@babel/plugin-proposal-object-rest-spread"]
}

and a .browserslistrc file with Edge 16 (among others)

The build step includes destructured object spread operators :(

Expected behavior

The spread operators are transpiled down to something more acceptable for the browsers I want to use based off of .browserslistrc.

Suggested solution(s)

Fast track #634

Your environment

Software Version(s)
TSDX latest
TypeScript latest
Browser Edge 16
npm/Yarn yarn
Node v10.16.2
Operating System MacOS latest
kylemh commented 4 years ago

I couldn't figure out or prevent my project from bundling with spread operator 😢

Ended up just slapping the Babel-CLI onto the end of the build process 🙃

Would love some help fixing this.

kylemh commented 4 years ago

https://github.com/boopathi/react-svg-loader/issues/289

Ah this is the problem

agilgur5 commented 4 years ago

@kylemh so does a .browserslistrc file work? In-line config for preset-env inside of babelrc should work, but we don't have tests for an external .browserslistrc file and I was concerned some of the path resolution might affect it.

agilgur5 commented 4 years ago

@kylemh following up on my previous question

kylemh commented 4 years ago

Ill jump into this ticket and the Storybook one tomorrow! I’ve got them both saved.

kylemh commented 4 years ago

Make it one more day... Sorry about the delay.

kylemh commented 4 years ago

thanks a ton @agilgur5 really helping me ❤️

hoping to get back to TSDX stuff soon

agilgur5 commented 4 years ago

@kylemh I manually tested a .browserslistrc while writing up #795 and can confirm it worked. Will even error out if you've got an unknown Browserslist query, typo, etc.

Probably still good to add an integration test for .browserslistrc to make sure it continues to work

kylemh commented 4 years ago

Right, sorry for continuing to comment, but I actually closed this when I realized that this was the problem.

agilgur5 commented 4 years ago

Yes, I realize that, but I had also asked above https://github.com/formium/tsdx/issues/655#issuecomment-608589483 if .browserslistrc actually does work or not which never got a response. I was able to test this myself now so have a confirmation on that.