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

Modernize things #421

Merged
merged 10 commits into from
Mar 20, 2018
Merged

Modernize things #421

merged 10 commits into from
Mar 20, 2018

Conversation

giuseppeg
Copy link
Collaborator

@giuseppeg giuseppeg commented Mar 17, 2018

I am removing gulp, babel-polyfill which we only needed because we used a Map in src/style.js.
I replaced the Map with an array. Also switched to babel-preset-env. Finally I am removing the benchmarks since there are better ones around http://necolas.github.io/react-native-web/benchmarks/ https://github.com/A-gambit/CSS-IN-JS-Benchmarks

tusbar and others added 8 commits December 15, 2017 01:30
babel-plugin-transform-runtime factorizes the helpers by using
core-js. This was making this library way too big.

core-js adds 7KB (gzipped) of overhead, while inlining the helpers (even
though some are duplicated) only adds 0.6KB (gzipped).

babel-preset-es2015 is pretty much deprecated, using preset-env allows
to stay up to date with the transforms.

Also remove preset-stage3 to only add transform-object-rest-spread as it
was the only transform necessary.

Finally, remove preset-minify as it was not used.
src/style.js Outdated
@@ -6,10 +6,9 @@ const styleSheetRegistry = new StyleSheetRegistry()
export default class JSXStyle extends Component {
static dynamic(info) {
return info
.map(tagInfo => {
const [baseId, props] = tagInfo
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We can just get rid of this and Babel won't inline the following helper :)

var _slicedToArray = (function() {
  function sliceIterator(arr, i) {
    var _arr = [];
    var _n = true;
    var _d = false;
    var _e = undefined;
    try {
      for (
        var _i = arr[Symbol.iterator](), _s;
        !(_n = (_s = _i.next()).done);
        _n = true
      ) {
        _arr.push(_s.value);
        if (i && _arr.length === i) break;
      }
    } catch (err) {
      _d = true;
      _e = err;
    } finally {
      try {
        if (!_n && _i["return"]) _i["return"]();
      } finally {
        if (_d) throw _e;
      }
    }
    return _arr;
  }
  return function(arr, i) {
    if (Array.isArray(arr)) {
      return arr;
    } else if (Symbol.iterator in Object(arr)) {
      return sliceIterator(arr, i);
    } else {
      throw new TypeError(
        "Invalid attempt to destructure non-iterable instance"
      );
    }
  };
})();

@@ -7,7 +7,8 @@ export default class JSXStyle extends Component {
static dynamic(info) {
return info
.map(tagInfo => {
const [baseId, props] = tagInfo
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

by getting rid of this Babel won't inline the following helper:

var _slicedToArray = (function() {
  function sliceIterator(arr, i) {
    var _arr = [];
    var _n = true;
    var _d = false;
    var _e = undefined;
    try {
      for (
        var _i = arr[Symbol.iterator](), _s;
        !(_n = (_s = _i.next()).done);
        _n = true
      ) {
        _arr.push(_s.value);
        if (i && _arr.length === i) break;
      }
    } catch (err) {
      _d = true;
      _e = err;
    } finally {
      try {
        if (!_n && _i["return"]) _i["return"]();
      } finally {
        if (_d) throw _e;
      }
    }
    return _arr;
  }
  return function(arr, i) {
    if (Array.isArray(arr)) {
      return arr;
    } else if (Symbol.iterator in Object(arr)) {
      return sliceIterator(arr, i);
    } else {
      throw new TypeError(
        "Invalid attempt to destructure non-iterable instance"
      );
    }
  };
})();

Copy link
Contributor

Choose a reason for hiding this comment

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

If you mean you want smaller output, you'll need to use other options like 'loose' mode because spec is default.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good point but I don't know if I can configure that per-plugin when using preset-env. In this case I can just write es5 myself

Copy link
Contributor

Choose a reason for hiding this comment

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

You can apply loose mode to all plugins or do them individually yeah. Of course that works too

@giuseppeg giuseppeg merged commit 2831798 into next Mar 20, 2018
@giuseppeg giuseppeg deleted the modernize-things branch March 20, 2018 14:02
rmdort pushed a commit to rmdort/styled-jsx that referenced this pull request Jun 20, 2018
* Use babel-preset-env and transform-object-rest-spread
* Remove transform-runtime and babel-polyfill
* Get rid of Gulp and use babel cli to build 
* Use an array instead of a Map in styled-jsx/style (`flush`). This way we don't need polyfills
rmdort pushed a commit to rmdort/styled-jsx that referenced this pull request Jul 3, 2018
* Use babel-preset-env and transform-object-rest-spread
* Remove transform-runtime and babel-polyfill
* Get rid of Gulp and use babel cli to build 
* Use an array instead of a Map in styled-jsx/style (`flush`). This way we don't need polyfills
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