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

Upgrade Babel dependency #48

Open
andrew-humu opened this issue Apr 12, 2019 · 3 comments · May be fixed by #49
Open

Upgrade Babel dependency #48

andrew-humu opened this issue Apr 12, 2019 · 3 comments · May be fixed by #49

Comments

@andrew-humu
Copy link

It would be nice to unlock the version of @babel/* dependencies required by this module.

Related to: #44

@andrew-humu andrew-humu linked a pull request Apr 12, 2019 that will close this issue
@aphofstede
Copy link

Updating the babel deps breaks the snapshot tests in the project, most of them are similar to:

  1) index
       should work with array:

      Error: Expected '"use strict";\n\nrequire("element-ui/lib/button/style.css");\n\nvar _button = _interopRequireDefault(require("element-ui/lib/button"));\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }\n\nnew Vue({\n  components: [_button["default"]]\n});' to equal 'require("element-ui/lib/button/style.css");\n\nvar _Button = _interopRequireDefault(require("element-ui/lib/button")).default;\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nnew Vue({\n  components: [_Button]\n});'
      + expected - actual

      -"use strict";
      -
       require("element-ui/lib/button/style.css");
       
      -var _button = _interopRequireDefault(require("element-ui/lib/button"));
      +var _Button = _interopRequireDefault(require("element-ui/lib/button")).default;
       
      -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
      +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
       
       new Vue({
      -  components: [_button["default"]]
      +  components: [_Button]
       });
      
      at assert (node_modules/expect/lib/assert.js:29:9)
      at Expectation.toEqual (node_modules/expect/lib/Expectation.js:81:30)
      at Context.toEqual (test/index-test.js:147:29)

Most of them look mostly cosmetic. The "use strict"; part is hard for me to judge in the context of this package. Anyone with more in-depth knowledge able to assess?

@andrew-humu
Copy link
Author

Babel 7 now assumes that files it processes are ES modules, by default. I believe there's a babel configuration to disable that if desired, but I don't see any reason to do so.

babel/babel#8394

@aphofstede
Copy link

aphofstede commented Apr 14, 2019

Yeah I thought the same, but the commonjs'ness of element-ui gave me pause.
Going through the new output files, this one looks suspicious to me (unexpected _Select var):

// test/fixtures/conditions/expected.js
"use strict";

require("element-ui/lib/select/style.css");

var _select = _interopRequireDefault(require("element-ui/lib/select"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

if (a === _select["default"]) { }

if (_Select) { }

_Select ? 'a' : 'b';
a ? _Select : 2;
_Select || 'a';
a || _Select;

Another mystery guest: (_Element)

// test/fixtures/import-all-css/expected.js
"use strict";

require("element-ui/lib/style.css");

var _lib = _interopRequireDefault(require("element-ui/lib"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

console.log(_lib["default"].Button);
console.log(_Element);

And one more: (same as above)

// test/fixtures/import-module/expected.js
"use strict";

require("element-ui/lib/abc/style.css");

var _abc = _interopRequireDefault(require("element-ui/lib/abc"));

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }

console.log(_abc["default"].Button);
console.log(_Element);

I would expect something like var _Element = bind({})(_abc["default"]);?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants