-
-
Notifications
You must be signed in to change notification settings - Fork 902
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add UMD build to npm package (#357)
Fixes #345.
- Loading branch information
Showing
11 changed files
with
237 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# UUID example Browser with UMD build | ||
|
||
``` | ||
npm install | ||
npm start | ||
``` | ||
|
||
Then navigate to `example.html`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<!DOCTYPE html> | ||
<title>UUID UMD example</title> | ||
<p>Please open the Developer Console to view output</p> | ||
<script src="./node_modules/uuid/dist/umd/uuid.min.js"></script> | ||
<script src="./node_modules/uuid/dist/umd/uuidv1.min.js"></script> | ||
<script src="./node_modules/uuid/dist/umd/uuidv3.min.js"></script> | ||
<script src="./node_modules/uuid/dist/umd/uuidv4.min.js"></script> | ||
<script src="./node_modules/uuid/dist/umd/uuidv5.min.js"></script> | ||
<script src="example.js"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* global uuid:false, uuidv1:false, uuidv3:false, uuidv4:false, uuidv5:false */ | ||
console.log('uuidv1()', uuidv1()); | ||
|
||
console.log('uuidv4()', uuidv4()); | ||
|
||
// ... using predefined DNS namespace (for domain names) | ||
console.log('uuidv3() DNS', uuidv3('hello.example.com', uuidv3.DNS)); | ||
|
||
// ... using predefined URL namespace (for, well, URLs) | ||
console.log('uuidv3() URL', uuidv3('http://example.com/hello', uuidv3.URL)); | ||
|
||
// ... using a custom namespace | ||
// | ||
// Note: Custom namespaces should be a UUID string specific to your application! | ||
// E.g. the one here was generated using this modules `uuid` CLI. | ||
const MY_NAMESPACE = '55238d15-c926-4598-b49d-cf4e913ba13c'; | ||
console.log('uuidv3() MY_NAMESPACE', uuidv3('Hello, World!', MY_NAMESPACE)); | ||
|
||
// ... using predefined DNS namespace (for domain names) | ||
console.log('uuidv5() DNS', uuidv5('hello.example.com', uuidv5.DNS)); | ||
|
||
// ... using predefined URL namespace (for, well, URLs) | ||
console.log('uuidv5() URL', uuidv5('http://example.com/hello', uuidv5.URL)); | ||
|
||
// ... using a custom namespace | ||
// | ||
// Note: Custom namespaces should be a UUID string specific to your application! | ||
// E.g. the one here was generated using this modules `uuid` CLI. | ||
// const MY_NAMESPACE = '1b671a64-40d5-491e-99b0-da01ff1f3341'; | ||
console.log('uuidv5() MY_NAMESPACE', uuidv5('Hello, World!', MY_NAMESPACE)); | ||
|
||
console.log('Same with default export'); | ||
|
||
console.log('uuid.v1()', uuid.v1()); | ||
console.log('uuid.v4()', uuid.v4()); | ||
console.log('uuid.v3() DNS', uuid.v3('hello.example.com', uuid.v3.DNS)); | ||
console.log('uuid.v3() URL', uuid.v3('http://example.com/hello', uuid.v3.URL)); | ||
console.log('uuid.v3() MY_NAMESPACE', uuid.v3('Hello, World!', MY_NAMESPACE)); | ||
console.log('uuid.v5() DNS', uuid.v5('hello.example.com', uuid.v5.DNS)); | ||
console.log('uuid.v5() URL', uuid.v5('http://example.com/hello', uuid.v5.URL)); | ||
console.log('uuid.v5() MY_NAMESPACE', uuid.v5('Hello, World!', MY_NAMESPACE)); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"name": "uuid-example-browser-umd", | ||
"version": "0.0.0", | ||
"private": true, | ||
"scripts": { | ||
"build": "true", | ||
"start": "npm run build && npx http-server . -o" | ||
}, | ||
"dependencies": { | ||
"uuid": "file:../../.local" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { terser } from 'rollup-plugin-terser'; | ||
|
||
function chunk(input, name) { | ||
return { | ||
input: `dist/esm-browser/${input}.js`, | ||
output: { | ||
file: `dist/umd/${name}.min.js`, | ||
format: 'umd', | ||
name, | ||
compact: true, | ||
}, | ||
plugins: [terser()], | ||
}; | ||
} | ||
|
||
export default [ | ||
chunk('index', 'uuid'), | ||
chunk('v1', 'uuidv1'), | ||
chunk('v3', 'uuidv3'), | ||
chunk('v4', 'uuidv4'), | ||
chunk('v5', 'uuidv5'), | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters