Skip to content

Added production ready settings for react theme #2587

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

Merged
merged 2 commits into from
Mar 8, 2018

Conversation

thangngoc89
Copy link
Contributor

Fixes #2579

thangngoc89 referenced this pull request in thangngoc89/bsb-theme-react Mar 8, 2018
@chenglou
Copy link
Member

chenglou commented Mar 8, 2018

Thanks! I'll try it.

@chenglou chenglou merged commit 067e32d into rescript-lang:master Mar 8, 2018
@@ -12,7 +12,7 @@
"subdirs" : true
},
"package-specs": [{
"module": "commonjs",
"module": "es6",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using es6 by default is probably a bad idea, as it'll decrease compatibility with various tools. I think you've already had issues using es6 modules with bs-jest? commonjs on the other hand is the lowest-common denominator. As far I understand, the primary benefit of using es6 is to be able to show off tiny hello world bundles, but I don't think that is justification enough for increasing friction for newcomers.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@thangngoc89 what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@glennsl I've successfully config bs-jest for working with es6, this is my current config:

"jest": {
    "transformIgnorePatterns": [
      "/node_modules\\/(?!bs-jest|bs-platform|reason-react|bs-react-test-renderer)/"
    ],
    "testMatch": [
      "**/__tests__/**/*_test.bs.js"
    ]
  }

This is nothing crazy, I'm telling jest to transpile bs-jest, bs-platform, reason-react, bs-react-test-renderer and friends because jest doesn't transpile anything in node_modules by default. Perhaps you would accept a PR to bs-jest's README about this @glennsl ?

the primary benefit of using es6 is to be able to show off tiny hello world bundles

Hmm, the main benefit is definitely not for the hello world, It's a good default for treeshaking and a small bundle in real world app. The ecosystem has adapted with ES6 modules and I would say it's sane to enable it right now.

Copy link
Contributor Author

@thangngoc89 thangngoc89 Mar 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A sidenote: You could set transformIgnorePatterns to [ ""] but that would introduced a lot of overhead.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure that es6 also works well with other tools than bs-jest?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me throw in my 2c. ES6 is the standard in frontend dev. If we want to be taken seriously as a replacement for Babel and friends, we need to show we care about bundle size.

Copy link
Contributor

@glennsl glennsl Mar 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you would accept a PR to bs-jest's README about this @glennsl ?

Definitely, but I don't think this is actually all the required configuration. Don't you need to add babel-jest too?

Hmm, the main benefit is definitely not for the hello world, It's a good default for treeshaking and a small bundle in real world app. The ecosystem has adapted with ES6 modules and I would say it's sane to enable it right now.

The few who require tiny bundle sizes can probably figure out how to enable es6 modules through some guide. I don't think it's a good idea to (possibly) sacrifice newcomer experience for the very minor convenience of having an advanced optimization enabled by default. At the very least I'd like to see this tested for a bit to have a better idea of its consequences before enabling it as the default.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. We can test it in master and release it (or not) based on that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely, but I don't think this is actually all the required configuration. Don't you need to add babel-jest too?

Yep. I do. I think it's best that we change this back to commonjs. Also I want to see this happens #2418 . This won't require a custom config for jest

Copy link
Member

@chenglou chenglou Mar 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, let's use commonjs and put a comment right above on using es6 (bsconfig.json parser accepts comments and trailing commas).

Edit: or maybe put it in webpack.config.js or README? @thangngoc89?

@thangngoc89 thangngoc89 deleted the thangngoc89-react-theme branch March 8, 2018 13:57
chenglou added a commit to chenglou/rescript-compiler that referenced this pull request Mar 13, 2018
chenglou added a commit that referenced this pull request Mar 13, 2018
* [Bsb] Revert the React template from es6 to commonjs

See #2587 (comment)

* Update README.md
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

Successfully merging this pull request may close these issues.

4 participants