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

Allow custom Babel config #36

Closed
lukeed opened this issue Dec 7, 2016 · 11 comments
Closed

Allow custom Babel config #36

lukeed opened this issue Dec 7, 2016 · 11 comments

Comments

@lukeed
Copy link

lukeed commented Dec 7, 2016

In stage 1 of the babelify transforms, we should be able to inject custom plugins. (and perhaps presets?).

For instance, decorators, async/await, and other ES7 goodies are untouchable right now. Doing this lets Babel compile is down to ES5 or ES6 before GCC sees it.

Some very common babel plugins that were missing & broke my build:

  • babel-plugin-transform-class-properties
  • babel-plugin-transform-decorators-legacy
  • babel-preset-stage-0

The simplest of errors resulted in an unsupported spread operator:

ERROR - Parse error. '}' expected
			todo => ({ ...todo, completed })
			           ^
@cramforce
Copy link
Owner

Sounds reasonable. A thing is that you almost certainly do not want babel-preset-stage-0. For good results it is very important the CC transpiles all the things it can transpile itself.

Any chance you have a sample project handy that could be included into the test suite?

@lukeed
Copy link
Author

lukeed commented Dec 7, 2016

Yeah, likely no presets.

I was converting Preact's TodoMVC.

@cramforce
Copy link
Owner

Cool. I will take a look tonight. Did you have to make any changes to the repo or just run splittable on some input?

@lukeed
Copy link
Author

lukeed commented Dec 7, 2016

Cool, thanks. I just ran Splittable. Normally I spin up Splittable without any issues. But this repo uses more ES6/7 features than I traditionally do.

@cramforce
Copy link
Owner

I have this working

splittable({
  modules: [
    './src/index',
  ],
  writeTo: './sample/out/',
  babel: {
    plugins: [
      'transform-object-rest-spread',
      ['transform-react-jsx', { pragma:'h' }]
    ],
  }
})

@lukeed
Copy link
Author

lukeed commented Dec 8, 2016

Is that doable right now? Or did it rely on changes you made to Splittable locally?

@cramforce
Copy link
Owner

I made local changes. But they seem to work. Will need some time to clean up and write tests.

@lukeed
Copy link
Author

lukeed commented Dec 8, 2016

Cool. Thanks @cramforce !

@cramforce
Copy link
Owner

PR in #41

Needs some final cleanup.

@lukeed
Copy link
Author

lukeed commented Dec 12, 2016

@cramforce Thanks!

cramforce added a commit that referenced this issue Dec 24, 2016
@cramforce
Copy link
Owner

@lukeed Please give it a shot. Published as 4.0.0

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

2 participants