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

Allow using the generator function on a HTML page directly #345

Closed
prantlf opened this issue Nov 17, 2019 · 3 comments
Closed

Allow using the generator function on a HTML page directly #345

prantlf opened this issue Nov 17, 2019 · 3 comments
Milestone

Comments

@prantlf
Copy link

prantlf commented Nov 17, 2019

The UUID generator can be built to a browser application using browserify, webpack, rollup or similar other bundler. However, if the application is built from pure JavaScript modules or AMD modules, this package cannot be used without an additional bundling work. (Scripts published from the NPM package cannot be loaded by the script element on a web page.)

How about including UMD modules in the NPM package, so that browser applications could load them directly, without each of them building such module themselves internally?

For example, by importing the UUID generator function globally:

<script src="https://unpkg.com/uuid@3.4.0/browser/v1.min.js"></script>
<script>
  var id = uuidv1();
  console.log(id);
</script>

Another example, requiring the UUID generator as an AMD module (using RequireJS, for example):

<script src="https://unpkg.com/requirejs@2.3.6/require.js"></script>
<script>
  require.config({
    paths: {uuidv4: 'https://unpkg.com/uuid@3.4.0/browser/v4.min'}
  });
  require(['uuidv4'], function(uuid) {
    var id = uuid();
    console.log(id);
  });
</script>
@ctavan ctavan added this to the 4.0.0 milestone Nov 17, 2019
@ctavan
Copy link
Member

ctavan commented Nov 17, 2019

@prantlf I'm considering to add a UMD build when releasing the v4.0.0 version of this module so that this library could be loaded directly through the various CDNs that just mirror npm package content.

Until then could you check if #302 (comment) works for you?

This was referenced Jan 27, 2020
ctavan added a commit that referenced this issue Jan 27, 2020
@ctavan
Copy link
Member

ctavan commented Jan 27, 2020

This has been merged to the next branch with #357 and will be released with the upcoming major version release.

@ctavan ctavan closed this as completed in 4e75adf Jan 28, 2020
@ctavan
Copy link
Member

ctavan commented Feb 24, 2020

We have just released uuid@7.0.0 which now features direct UMD builds again: https://github.com/uuidjs/uuid#umd-builds

Please feel free to open a new issue if you encounter any issues with the new version.

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

No branches or pull requests

2 participants