mirror of
https://github.com/hanzoai/uuid.git
synced 2026-09-24 17:04:02 +00:00
fix!: make browser exports the default (#901)
Restore browser build as the default in `package.json#exports`
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
*.tgz
|
||||
browserstack.err
|
||||
dist/
|
||||
dist-browser/
|
||||
dist-*/
|
||||
.build/
|
||||
local.log
|
||||
logs/
|
||||
|
||||
@@ -1,22 +1,8 @@
|
||||
```javascript --hide
|
||||
import crypto from 'node:crypto';
|
||||
|
||||
runmd.onRequire = (path) => {
|
||||
if (path == 'rng') return fun;
|
||||
return path.replace(/^uuid/, './dist/');
|
||||
};
|
||||
|
||||
// Shim Date and crypto so generated ids are consistent across doc revisions
|
||||
runmd.Date.now = () => 1551914748172;
|
||||
|
||||
let seed = 0xdefaced;
|
||||
crypto.randomFillSync = function (a) {
|
||||
for (let i = 0; i < a.length; i++) a[i] = (seed = (seed * 0x41a7) & 0x7fffffff) & 0xff;
|
||||
return a;
|
||||
};
|
||||
|
||||
// Prevent usage of native randomUUID implementation to ensure deterministic UUIDs
|
||||
crypto.randomUUID = undefined;
|
||||
```
|
||||
|
||||
# uuid [](https://github.com/uuidjs/uuid/actions?query=workflow%3ACI) [](https://github.com/uuidjs/uuid/actions/workflows/browser.yml)
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as uuid from './node_modules/uuid/dist-browser/index.js';
|
||||
import * as uuid from './node_modules/uuid/dist/index.js';
|
||||
import './node_modules/lodash/lodash.js';
|
||||
import './node_modules/benchmark/benchmark.js';
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import * as uuid from './node_modules/uuid/dist-browser/index.js';
|
||||
import * as uuid from './node_modules/uuid/dist/index.js';
|
||||
import {
|
||||
MAX as MAX_UUID,
|
||||
NIL as NIL_UUID,
|
||||
@@ -14,7 +14,7 @@ import {
|
||||
v6 as uuidv6,
|
||||
v6ToV1 as uuidv6ToV1,
|
||||
v7 as uuidv7,
|
||||
} from './node_modules/uuid/dist-browser/index.js';
|
||||
} from './node_modules/uuid/dist/index.js';
|
||||
|
||||
// Import attribute syntax is still awaiting finalization. In the meantime we
|
||||
// use dynamic import to allows to specifyg both "assert" and "with" clauses.
|
||||
|
||||
+6
-6
@@ -20,20 +20,20 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"uuid": "./dist/bin/uuid"
|
||||
"uuid": "./dist-node/bin/uuid"
|
||||
},
|
||||
"sideEffects": false,
|
||||
"types": "./dist/index.d.ts",
|
||||
"exports": {
|
||||
".": {
|
||||
"browser": "./dist-browser/index.js",
|
||||
"node": "./dist-node/index.js",
|
||||
"default": "./dist/index.js"
|
||||
},
|
||||
"./package.json": "./package.json"
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"dist-browser",
|
||||
"dist-node",
|
||||
"!**/test"
|
||||
],
|
||||
"devDependencies": {
|
||||
@@ -71,7 +71,7 @@
|
||||
"build": "./scripts/build.sh",
|
||||
"build:watch": "tsc --watch -p tsconfig.json",
|
||||
"bundlewatch": "npm run pretest:browser && bundlewatch --config bundlewatch.config.json",
|
||||
"docs:diff": "npm run docs && git diff --quiet README.md",
|
||||
"docs:diff": "npm run docs && git diff --quiet -I \"[0-9a-f-]{36}\" README.md",
|
||||
"docs": "npm run build && npx runmd --output=README.md README_js.md",
|
||||
"eslint:check": "eslint src/ test/ examples/ *.[jt]s",
|
||||
"eslint:fix": "eslint --fix src/ test/ examples/ *.[jt]s",
|
||||
@@ -95,8 +95,8 @@
|
||||
"test:benchmark": "cd examples/benchmark && npm test",
|
||||
"test:browser": "wdio run ./wdio.conf.js",
|
||||
"test:node": "npm-run-all --parallel examples:node:**",
|
||||
"test:watch": "node --test --enable-source-maps --watch dist/test/*.js",
|
||||
"test": "node --test --enable-source-maps dist/test/*.js"
|
||||
"test:watch": "node --test --enable-source-maps --watch dist-node/test/*.js",
|
||||
"test": "node --test --enable-source-maps dist-node/test/*.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
||||
+22
-20
@@ -1,8 +1,8 @@
|
||||
#!/bin/bash -eu
|
||||
|
||||
# This script generates 4 builds, as follows:
|
||||
# - dist: ESM build for Node.js
|
||||
# - dist-browser: ESM build for the Browser
|
||||
# - dist: ESM build for the Browser
|
||||
# - dist-node: ESM build for Node.js
|
||||
#
|
||||
# Note: that the "preferred" build for testing (local and CI) is the ESM build,
|
||||
# except where we specifically test the other builds
|
||||
@@ -13,45 +13,47 @@ set -e # exit on error
|
||||
ROOT=$(builtin cd $(pwd)/$(dirname "$0")/..; pwd)
|
||||
|
||||
# Prep TS output dir
|
||||
NODE_DIST_DIR="$ROOT/dist"
|
||||
BROWSER_DIST_DIR="$ROOT/dist-browser"
|
||||
echo "Building in $NODE_DIST_DIR and $BROWSER_DIST_DIR"
|
||||
DIST_DIR="$ROOT/dist"
|
||||
NODE_DIST_DIR="$ROOT/dist-node"
|
||||
echo "Building in $DIST_DIR and $NODE_DIST_DIR"
|
||||
|
||||
cd "$ROOT" || exit 1
|
||||
|
||||
rm -rf "$NODE_DIST_DIR" "$BROWSER_DIST_DIR"
|
||||
mkdir -p "$NODE_DIST_DIR"
|
||||
# Remove old builds
|
||||
rm -rf $DIST_DIR*
|
||||
|
||||
# Build each module type
|
||||
# Make default dist dir
|
||||
mkdir -p "$DIST_DIR"
|
||||
|
||||
# Compile typescript
|
||||
echo "Compiling TypeScript files to $NODE_DIST_DIR"
|
||||
|
||||
tsc -p tsconfig.json
|
||||
|
||||
# Clone files for browser builds
|
||||
cp -pr "$NODE_DIST_DIR" "$BROWSER_DIST_DIR"
|
||||
# Clone files for node builds
|
||||
cp -pr "$DIST_DIR" "$NODE_DIST_DIR"
|
||||
|
||||
# Remove browser files from non-browser builds
|
||||
# Remove browser files in node build
|
||||
for FILE in ${NODE_DIST_DIR}/*-browser*; do
|
||||
rm -f $FILE
|
||||
done
|
||||
|
||||
# Move browser files into place for browser builds
|
||||
# Move browser files into place for default build
|
||||
(
|
||||
# Temporarily cd into BROWSER_DIST_DIR to avoid having to deal with
|
||||
# "-browser" appearing in both the dir name and file name of FILE's full
|
||||
# path
|
||||
cd "$BROWSER_DIST_DIR"
|
||||
cd "$DIST_DIR"
|
||||
|
||||
for FILE in *-browser*;do
|
||||
mv "$FILE" "${FILE/-browser/}"
|
||||
done
|
||||
)
|
||||
|
||||
# Remove type definitions
|
||||
# Remove type definition files where they're not needed
|
||||
(
|
||||
cd "$NODE_DIST_DIR"
|
||||
find . -name '*.d.ts' -exec rm -f {} \;
|
||||
)
|
||||
|
||||
# Copy bin files to dist
|
||||
cp -pr "$NODE_DIST_DIR/../src/bin" "$NODE_DIST_DIR"
|
||||
# Copy bin files into place
|
||||
cp -pr "$ROOT/src/bin" "$NODE_DIST_DIR"
|
||||
|
||||
if [ "${1-}" != "--no-pack" ]; then
|
||||
# Prep tarball dir
|
||||
|
||||
Reference in New Issue
Block a user