-
Notifications
You must be signed in to change notification settings - Fork 4
ES6 Modules #3
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
base: master
Are you sure you want to change the base?
ES6 Modules #3
Conversation
|
Since you are contributing in various place, I'd like to tell you how all my repositories are, in terms of consistency, and how I want to keep it that way. ESMThe entry point of any ESM module is Every ESM import should be Web compatible unless it's not possible other ways. Example, If there is no syntax to do special things like CJS would do, then it's OK to let bundlers resolve that (i.e. The entry point should be the CJSThe entry point of any CJS module is You can create out of the box CJS equivalent via ascjs and the command The entry point should be the No interoperabilityNothing between CJS and ESM is shared, I terms of files, those are two pure, independent, different, module systems. WebThe main entry point for the web, if any, is the UMDI don't believe in UMD. I publish modules that work either on the web as global exports, or as CJS or as ESM. UMD makes no sense these days, because UMD cannot deliver ESM and also it cannot deliver for other platforms different from NodeJS. Yes, I publish modules compatible also with GJS, or JSC, or even Nashorn, I don't want over bloated fairy tales in my repositories, and I consider UMD one of those. A single source of truthSometimes it's the In the first case, I usually write ES5 compatible syntax myself to avoid the need of transpilers or over bloated final output due transpilers. As example, However, like in hyperHTML case, if I pay attention to obvious things that bloat the transpilation without any real-world improvement (usually quite the opposite, where everything goes slower on already slower browsers) I write relatively modern code but I avoid everything that involves This also helps with performance, whenever it's cryptical. Anyway, to close this chapter, whenever somebody would like to help with a PR, there should be only changes in such source of truth, and an environment easy enough to install via Apologies for the long answer. |
|
About this PR, please follow above convention. The You can remove the exporting bit at the end of index.js file, since once there are 3 ways to load it it's clear which part should do what (i.e. the CJS/ESM should just export a module while the browser should overwrite). It might be interesting to figure out how to create these 3 distinct files so that maybe, an extra If you think it's too much, I'll try to have a go whenever I have time, but I'm surrounded by requests these days and I am a full time employee and I also have a life after that ( or trying to 😂 ) so thanks for your help or patience. |
|
Thanks for the instructions on your repository conventions.
I am really confused...If CJS is derived from ESM (via ascjs), how are they not shared? Rollup + plugins seems fine to convert to the other formats without bloat (though I know Babel may add bloat). What problems are you trying to avoid by insisting on the distinctness of each module system? While the named + default exports can be an issue, IIRC, Rollup, at least with plugins, allows a way around this issue...
You mean they are not live-loading any common file, but they may be auto-derived from one? Otherwise, I really don't understand what you mean...
By "min option", would Rollup adding a minified browser build script file there be ok? Ok, I think re: everything else... By the way, as far as coding conventions, are you not inclined to use ESLint? Might help with the ES5 enforcement not to mention catching bugs for the rest of us who can make mistakes. :-) |
d67558a to
e0bff6d
Compare
…add `module` to `package.json` and change `main`; add `unpkg` - npm: Add recommended fields to `package.json`
|
I've updated this PR per my understanding of your instructions, but let me know what further needs fixing... I didn't remove the lines at the end of index.js because it is currently derived from core.js (via Rollup). If you want me to add a Rollup plugin routine to strip out the code which is not relevant for the browser or CJS, let me know. Btw, that block at the end is problematic in a different way now that there is no |
|
nothing between CJS and ESM is shared means that a file outside cjs or esm folder cannot be used in both modules systems. There is no
Those are different modules system, I don't care about bundlers 'cause bundlers can work out what to import, standard ESM doesn't. |
I don't care much.
I have 100% code coverage to catch bugs, linter is less important for that.
if there are tests and test coverage, mistakes are easy to avoid. I don't care about ESLint because it brings in a lot of waste of time discussing between |
add
moduletopackage.jsonand changemainpackage.jsonThe source is the same as before except with
use strictand the IIFE removed (given module context), indentation adjusted accordingly, and and of course the export altered.