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

Added UMD #3377

Merged
merged 4 commits into from
Jun 13, 2024
Merged

Added UMD #3377

merged 4 commits into from
Jun 13, 2024

Conversation

redexp
Copy link
Contributor

@redexp redexp commented May 16, 2024

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

No braking changes, but now this file can be treat as module for commonjs or require.js or have regular global Janus var
@januscla
Copy link

Thanks for your contribution, @redexp! Please make sure you sign our CLA, as it's a required step before we can merge this.

@redexp
Copy link
Contributor Author

redexp commented May 16, 2024

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.

@lminiero
Copy link
Member

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.

@redexp
Copy link
Contributor Author

redexp commented May 17, 2024

linter errors on typeof define I think if I change it to typeof root.define then it should pass linter

Copy link
Member

@atoppi atoppi left a comment

Choose a reason for hiding this comment

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

Please address the linting issues.

I see nothing wrong about the PR.
If @lminiero is fine with moving the Janus definition from the top level to an immediately invoked function then we're good to go.

@redexp
Copy link
Contributor Author

redexp commented May 23, 2024

@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

@atoppi
Copy link
Member

atoppi commented May 23, 2024

@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).

@redexp
Copy link
Contributor Author

redexp commented Jun 13, 2024

@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

@atoppi
Copy link
Member

atoppi commented Jun 13, 2024

Merging, I'll figure out how to better fix the eslint stuff by myself.

@atoppi atoppi merged commit 22085e7 into meetecho:master Jun 13, 2024
8 checks passed
atoppi added a commit that referenced this pull request Jun 13, 2024
- package.json and package-losck.json have been moved to project root
- eslint.config.mjs created in the project root
- lint every script
- fix rollup related scripts after the merging of #3377
@atoppi
Copy link
Member

atoppi commented Jun 13, 2024

@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?

@redexp
Copy link
Contributor Author

redexp commented Jun 14, 2024

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();
	}

@atoppi
Copy link
Member

atoppi commented Jun 14, 2024

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.

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

Successfully merging this pull request may close these issues.

4 participants