Skip to content

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

@prantlf

Description

@prantlf

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>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions