Skip to content

[WIP]: ES6 Modules#735

Closed
leobalter wants to merge 10 commits into
qunitjs:masterfrom
leobalter:707-es6-modules
Closed

[WIP]: ES6 Modules#735
leobalter wants to merge 10 commits into
qunitjs:masterfrom
leobalter:707-es6-modules

Conversation

@leobalter

Copy link
Copy Markdown
Member

This is a WIP.

I've tried to set everything in ES6 modules, which showed to be more difficult than I thought with all the interdependencies in our code.

Currently, we need to make every module true independent, with that we can achieve the desired progress in this PR.

Also, the Browserify with 6to5 plugins aren't working as I expected. Bundling things still get then to use a require system, which I'm not aiming.

I'll follow @jzaefferer's suggestion and try http://jspm.io/

@leobalter

Copy link
Copy Markdown
Member Author

Other problem: I still need to see how to handle JSCS to accept ES6. Probably easy, I just still need to go that further.

@jzaefferer

Copy link
Copy Markdown
Member

I still need to see how to handle JSCS to accept ES6. Probably easy, I just still need to go that further.

We're not running jshint and jscs against src/ anyway, right? As long as the output in dist/ is more or less the same, there shouldn't be much of a difference.

Although, with proper modules and dependencies actually defined, we should also be able to validate src files directly...

Comment thread package.json Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Let's stick with fixed version numbers, drop the ^.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

wip. I'll fix that anyway.

@leobalter

Copy link
Copy Markdown
Member Author

Although, with proper modules and dependencies actually defined, we should also be able to validate src files directly...

One of my main ideas on converting our modules into the es6 format is to allow running jshint and jscs against src/ files, are they're the ones we should test, not a built file.

Also, JSHint helped me a lot on fixing most of dependencies connections in this PR.

Comment thread src/core.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why is this import down here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

interdependency issue. Test need QUnit.config properly set. :(

@jzaefferer

Copy link
Copy Markdown
Member

Well, now I see what you're talking about. Having modules depend on core, while those modules are also imported by core, is pretty bad. I think we need to, eventually, get rid of all these circular dependencies.

That said, overall it looks like we're on the right track. The import and export statements make sense and are easy enough to follow.

Comment thread src/equiv.js

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

this file got a huge diff because the indentation level reduced here. To ignore the whitespace change, see this diff including the ?w=1 parameter.

@jzaefferer

Copy link
Copy Markdown
Member

Instead of jspm we should try to use esperanto, like we now do (or started doing) in PEP: jquery-archive/PEP#157

@leobalter

Copy link
Copy Markdown
Member Author

This is getting more complex than expected and than I desired.

We have a lot of interdependencies that brings that complexity, I can make some inline comments to show it.

running grunt build will show some of the missing parts, but even if we solve the remaining, I don't like the interdependencies as they are right now. Solving them will look like a totally rewritten code, even if I don't try this.

At least, equiv, jsdiff and dump are easier to treat, as we still need to solve problems in test, assert, and the html reporter modules.

Comment thread src/core.js

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

we don't have the window as the global reference with these modules, it's necessary to fix it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does that only apply to window? What about setTimeout and other globals? How do you access the global scope correctly?

@leobalter

Copy link
Copy Markdown
Member Author

I believe it's better stop this PR for now, and treat some circular dependencies that will allow us to turn everything into ES6 Modules with something not such aggressive in the changes.

The code isn't designed for modules, but I've identified a lot of good and bad things in this PR which I'll will help in future work.

Some of the good parts:

  • esperanto worked just fine
  • jsdiff, equiv and dump will be easy to handle
  • The grunt-esperanto module is getting some improvements to be able to used with UMD

Some parts still needed to improve:

  • The html reporter has some circular dependencies on core's config and urlParams. That shouldn't happen. Maybe the build should come from it, as it requires QUnit and attach the logging methods.
  • Test and Assert share a lot of cross dependencies with core, most of them can be identified to be detached from core.

@leobalter leobalter closed this Feb 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

3 participants