-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
[WIP] es6 with babel/generator-babel-boilerplate #968
Conversation
@marcandre I've reached in this first WIP commit to build transpiled source into I also noticed that since last week there is also a deprecation notice while transpiling with this stack. IMO this is not very important for now, we'll switch to esperanto or rollup to transpile later when change would be really needed. Could you have a quick glance to this first commit and tell me if you think this is the right direction to take? Thx a bunch |
Hi Guillaume, this is exciting. Looks like the right direction for sure. Not too sure what you mean by "adapt Parsley files", but I making the tests run is the next step. Then we can start having fun using the ES6 features. |
I restructured the commit, so that the diff can be understood. I edited my comment coz I was looking at the |
I meant that it cannot work out of the box just by replacing defines by imports/exports. I do not handle all the es6 subtleties to make it work yet. We'll have to make some changes to work that way. Then yes, once working basically in the browser, I'll have to have a look to test suite. Regarding transpiled files in I'll try to have a look this week end, but not 100% sure, it's back to school here and got a lot to do :( Best |
You're sure? I didn't check, but I assumed it should work fine. ES3/5 is valid ES6.
I'd say that commits should only touch |
Yes but I suspect requirejs behaves not exactly as an import/export does. I think it would need some adjustments
Ok we are on the same page here. Sorry then for having comimtted the dist files now :s I'll ammend the commit |
No problem at all. I already did it. And split your commit in two, so conflicts are easier to fix. |
Changed paths to be relative. Now I think the next step is to have the tests run. |
// Return undefined if applied to non existing DOM element | ||
if (!$(this).length) { | ||
ParsleyUtils.warn('You must bind Parsley on an existing element.'); | ||
import $ from 'jQuery'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The string needs to be exactly the same as the name of the module that you're requiring in. In this case, it should be jquery
(and not jQuery
), as that's the name of the module that jQuery registers itself under on npm, Bower, and so on.
I haven't looked too thoroughly at this PR, but I would expect you to also need to add jquery
as a dep in package.json
. Atm it's only specified in the Bower package. The reason for this is that the behavior of the module bundler used by the Babel boilerplate effectively mimics a Node CommonJS module. In the same way that a Node script will search through node_modules
to resolve packages, libs built with the boilerplate will do the same.
Lmk if this helps, or if you have other Q's!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx for the quick feedback. I made the tweaks you pointed out, still won't load properly though... Note that the "test" is just the boilerplate test requiring our lib...
[~/parsley(es6)]$ gulp
[DEPRECATION NOTICE] Esperanto is no longer under active development. To convert an ES6 module to another format, consider using Babel (https://babeljs.io)
[22:28:08] Using gulpfile ~/parsley/gulpfile.js
[22:28:08] Starting 'lint-src'...
[22:28:08] Starting 'lint-test'...
[22:28:08] Finished 'lint-test' after 82 ms
[22:28:08] Finished 'lint-src' after 385 ms
[22:28:08] Starting 'test'...
[22:28:10] 'test' errored after 1.45 s
[22:28:10] Error in plugin 'gulp-mocha'
Message:
Cannot find module 'jquery'
Details:
code: MODULE_NOT_FOUND
Stack:
Error: Cannot find module 'jquery'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/Users/mal/parsley/src/parsley.js:12:15)
at Module._compile (module.js:460:26)
at normalLoader (/Users/mal/parsley/node_modules/babel-core/lib/api/register/node.js:199:5)
at Object.require.extensions.(anonymous function) [as .js] (/Users/mal/parsley/node_modules/babel-core/lib/api/register/node.js:216:7)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
Any idea?
The build is currently failing because jQuery isn't required in a file that is trying to using it. With ES6 modules, it's best to think of each file as existing in its own little universe. If @marcandre if you want to set aside some time to figure this out synchronously (google hangouts, gitter, IRC, etc.), let me know and we can schedule a meeting. |
Thanks for the feedback.
I guess I'll have a look later on, as a quick search didn't come up with an obvious solution, but of course if you happen to have a solution for me... 😄 |
This is likely because the tests are running in a Node environment, and not in a browser. jQuery doesn't Just Work© in Node. This is 'cause it's built for the browser: primarily as a wrapper for the DOM API. And Node doesn't implement the DOM. There are at least two approaches you could take: I usually use JSDom, though for bigger libraries and apps Karma is a fantastic tool. More specifically, I tend to use simple-jsdom, which is by far the easiest way I know of to get jQuery tests working on the server. The README explains it, but it's as simple as:
Then, somewhere in your test setup script, add this code:
In ES6, that would be: import simpleJSDom from 'simple-jsdom';
simpleJSDom.install(); You will need to do this before jQuery is loaded. Hope that helps! |
9311ef0
to
f941c0c
Compare
Just awesome, things are working very well! I'm adapting the tests and moving them from Thanks again @jmeas <3 <3 |
Wow, this is great news! Good work guys! 💯 |
Woo! Glad to hear it! |
8a9d7a0
to
416afc5
Compare
This is a solid point. Parsley first aim was to be compatible with most browsers, IE8 for instance that we still support here @Wisembly :s Could be great to specify browser compatibility for regular @marcandre is test-suite still runnable on browser ? If so, I could check on browserstack on various browsers. Best |
Indeed, forgot about the IIUC, the Current setup to run in the browser is that |
Mhm.
Yup, that's right.
This might cause some folks to bundle it twice, and if I remember correctly the shims together are not a negligible file size. |
Updated to doc, Changelog for dependency on |
Ok good for me 👍 (except maybe this weird unsquashed commit :p) |
I'll let you do the merge, the push and the tag. I'll publish to npm once done. |
Note: gulp-docco doesn't work, and not easy to fix as the table of contents goes against the grain of gulp
Merged in after final tweaks 😄 👯 |
Just realized the |
woooo! 🎉 |
🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 🎉 |
Cool, the tests tab now works, and |
@marcandre / @guillaumepotier how has this branch been working out for y'all? Any bugs or problems with the ES2015-ified build? |
No issue at all, works well. |
ES6
Use es6 for Parsley development and build it fully transpiled into
dist/
. Should lead to2.3.0
version which do not bring any new feature nor BC break.TODO