Closed redexp closed 3 months ago
Thanks for your contribution, @redexp! Please make sure you sign our CLA, as it's a required step before we can merge this.
Another pros - you can define as many private var as you need. Like that var defaultExtension
that I assumed should be private, but right now it's in global scope and could be overwritten in some other file.
I'm not knowledgeable about JavaScript enough to have an opinion: I only care that this doesn't break existing demos. I'll leave @atoppi to evaluate if this could cause us problems. I do notice that this apparently didn't pass our linter check on Github Actions, though.
linter errors on typeof define
I think if I change it to typeof root.define
then it should pass linter
@atoppi
28:38 error 'define' is not defined no-undef
29:3 error 'define' is not defined no-undef
30:43 error 'module' is not defined no-undef
31:3 error 'module' is not defined no-undef
@redexp yeah, please fix those and also the issues about indentation.
If you wanna test locally before triggering our github workflow, just use eslint janus.js
with our eslint configuration file (.eslintrc.js
).
@atoppi I'v added rule to ignore one indent in main part code. It's ok practice with UMD, eslint itself shows example how to do it
Merging, I'll figure out how to better fix the eslint stuff by myself.
@redexp add to do a bunch of modifications due to the broken rollup script after your merge. Can you test if this still works for you after the commit above?
instead of this
var Janus = (function (factory) {
if (...) {
...
} else if (typeof window === 'object') {
return factory();
}
I'd rather do like
(function (factory) {
if (...) {
...
} else if (typeof window === 'object') {
window.Janus = factory();
}
Unfortunately we have a rollup script that bundles janus.js
in an es module.
It basically takes this template, replaces @JANUS_CODE@
with the content of janus.js
and exports a Janus
object, hence we need that object to be explicitly declared by janus.js
.
No braking changes, but now this file can be treat as module for commonjs or require.js or have regular global Janus var
I used this UMD template https://github.com/umdjs/umd/blob/master/templates/returnExports.js