build: use npm pack tarball for local examples and testing instead of .local (#859)

This commit is contained in:
Robert Kieffer
2025-01-09 11:31:51 -10:00
committed by GitHub
parent bbad5197b3
commit cd2a532539
39 changed files with 9516 additions and 13637 deletions
+2 -2
View File
@@ -14,13 +14,13 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 22.x
- run: npm ci
- run: npm run lint
- run: npm run docs:diff
test:
runs-on: ubuntu-latest
needs: lint
strategy:
fail-fast: false
matrix:
@@ -32,7 +32,7 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: npm ci
- run: npm run test
- run: npm run test:node
- run: npm run test:pack
+2
View File
@@ -1,6 +1,8 @@
*.tgz
browserstack.err
dist/
.build/
local.log
logs/
node_modules/
examples/**/package-lock.json
-9
View File
@@ -1,9 +0,0 @@
# Local Fake Module for Testing
This is a local fake module for use in the [examples](../examples) and browser tests (that are
based on the examples) where we reference the `uuid` module with a local `file:` path in the
respective `package.json` files.
We must ensure that the local module does not contain locally installed dev dependencies in a
`node_modules` hence this "fake module" that just consists of symbolic links and imitates the final
contents of the npm tarball.
-1
View File
@@ -1 +0,0 @@
../../dist
-1
View File
@@ -1 +0,0 @@
../../package.json
-1
View File
@@ -1 +0,0 @@
../../v1.js
-1
View File
@@ -1 +0,0 @@
../../v1tov6.js
-1
View File
@@ -1 +0,0 @@
../../v3.js
-1
View File
@@ -1 +0,0 @@
../../v4.js
-1
View File
@@ -1 +0,0 @@
../../v5.js
-1
View File
@@ -1 +0,0 @@
../../v6.js
-1
View File
@@ -1 +0,0 @@
../../v6tov1.js
-1
View File
@@ -1 +0,0 @@
../../v7.js
-1
View File
@@ -1 +0,0 @@
../../wrapper.mjs
-1
View File
@@ -1,4 +1,3 @@
.local/
dist/
node_modules/
README.md
+1 -1
View File
@@ -33,6 +33,6 @@ export default [
},
},
{
ignores: ['eslint.config.cjs', '.local/', '**/dist/', 'node_modules/'],
ignores: ['eslint.config.cjs', '**/dist/', 'node_modules/'],
},
];
-138
View File
@@ -1,138 +0,0 @@
{
"name": "uuid-benchmark",
"version": "0.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "uuid-benchmark",
"version": "0.0.0",
"dependencies": {
"uuid": "file:../../.local/uuid"
},
"devDependencies": {
"benchmark": "^2.1.4"
}
},
"../../.local/uuid": {
"version": "10.0.0",
"funding": [
"https://github.com/sponsors/broofa",
"https://github.com/sponsors/ctavan"
],
"license": "MIT",
"bin": {
"uuid": "dist/esm/bin/uuid"
},
"devDependencies": {
"@babel/eslint-parser": "7.24.8",
"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",
"@eslint/js": "9.7.0",
"@types/eslint__js": "8.42.3",
"@wdio/browserstack-service": "8.39.1",
"@wdio/cli": "8.39.1",
"@wdio/jasmine-framework": "8.39.1",
"@wdio/local-runner": "8.39.1",
"@wdio/spec-reporter": "8.39.0",
"@wdio/static-server-service": "8.39.0",
"bundlewatch": "0.3.3",
"eslint": "9.7.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"globals": "15.8.0",
"husky": "9.1.1",
"jest": "29.7.0",
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
"typescript": "5.5.3",
"typescript-eslint": "8.0.0-alpha.30"
}
},
"node_modules/benchmark": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/benchmark/-/benchmark-2.1.4.tgz",
"integrity": "sha1-CfPeMckWQl1JjMLuVloOvzwqVik=",
"dev": true,
"dependencies": {
"lodash": "^4.17.4",
"platform": "^1.3.3"
}
},
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
},
"node_modules/platform": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz",
"integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==",
"dev": true
},
"node_modules/uuid": {
"resolved": "../../.local/uuid",
"link": true
}
},
"dependencies": {
"benchmark": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/benchmark/-/benchmark-2.1.4.tgz",
"integrity": "sha1-CfPeMckWQl1JjMLuVloOvzwqVik=",
"dev": true,
"requires": {
"lodash": "^4.17.4",
"platform": "^1.3.3"
}
},
"lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"dev": true
},
"platform": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/platform/-/platform-1.3.6.tgz",
"integrity": "sha512-fnWVljUchTro6RiCFvCXBbNhJc2NijN7oIQxbwsyL0buWJPG85v81ehlHI9fXrJsMNgTofEoWIQeClKpgxFLrg==",
"dev": true
},
"uuid": {
"version": "file:../../.local/uuid",
"requires": {
"@babel/eslint-parser": "7.24.8",
"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",
"@eslint/js": "9.7.0",
"@types/eslint__js": "8.42.3",
"@wdio/browserstack-service": "8.39.1",
"@wdio/cli": "8.39.1",
"@wdio/jasmine-framework": "8.39.1",
"@wdio/local-runner": "8.39.1",
"@wdio/spec-reporter": "8.39.0",
"@wdio/static-server-service": "8.39.0",
"bundlewatch": "0.3.3",
"eslint": "9.7.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"globals": "15.8.0",
"husky": "9.1.1",
"jest": "29.7.0",
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
"typescript": "5.5.3",
"typescript-eslint": "8.0.0-alpha.30"
}
}
}
}
+2 -1
View File
@@ -5,10 +5,11 @@
"scripts": {
"build": "true",
"start": "npm run build && npx http-server . -o",
"pretest": "HUSKY=0 npm install --no-package-lock",
"test": "node node.js"
},
"dependencies": {
"uuid": "file:../../.local/uuid"
"uuid": "file:../../.build/uuid.tgz"
},
"devDependencies": {
"benchmark": "^2.1.4"
-91
View File
@@ -1,91 +0,0 @@
{
"name": "uuid-example-browser-esmodules",
"version": "0.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "uuid-example-browser-esmodules",
"version": "0.0.0",
"dependencies": {
"uuid": "file:../../.local/uuid"
}
},
"../../.local/uuid": {
"version": "10.0.0",
"funding": [
"https://github.com/sponsors/broofa",
"https://github.com/sponsors/ctavan"
],
"license": "MIT",
"bin": {
"uuid": "dist/esm/bin/uuid"
},
"devDependencies": {
"@babel/eslint-parser": "7.24.8",
"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",
"@eslint/js": "9.7.0",
"@types/eslint__js": "8.42.3",
"@wdio/browserstack-service": "8.39.0",
"@wdio/cli": "8.39.1",
"@wdio/jasmine-framework": "8.39.0",
"@wdio/local-runner": "8.39.0",
"@wdio/spec-reporter": "8.39.0",
"@wdio/static-server-service": "8.39.0",
"bundlewatch": "0.3.3",
"eslint": "9.7.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"globals": "15.8.0",
"husky": "9.1.1",
"jest": "29.7.0",
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
"typescript": "5.5.3",
"typescript-eslint": "8.0.0-alpha.30"
}
},
"node_modules/uuid": {
"resolved": "../../.local/uuid",
"link": true
}
},
"dependencies": {
"uuid": {
"version": "file:../../.local/uuid",
"requires": {
"@babel/eslint-parser": "7.24.8",
"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",
"@eslint/js": "9.7.0",
"@types/eslint__js": "8.42.3",
"@wdio/browserstack-service": "8.39.0",
"@wdio/cli": "8.39.1",
"@wdio/jasmine-framework": "8.39.0",
"@wdio/local-runner": "8.39.0",
"@wdio/spec-reporter": "8.39.0",
"@wdio/static-server-service": "8.39.0",
"bundlewatch": "0.3.3",
"eslint": "9.7.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"globals": "15.8.0",
"husky": "9.1.1",
"jest": "29.7.0",
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
"typescript": "5.5.3",
"typescript-eslint": "8.0.0-alpha.30"
}
}
}
}
+1 -1
View File
@@ -7,6 +7,6 @@
"start": "npm run build && npx http-server . -o"
},
"dependencies": {
"uuid": "file:../../.local/uuid"
"uuid": "file:../../.build/uuid.tgz"
}
}
-1
View File
@@ -1 +0,0 @@
dist/
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -3,11 +3,11 @@
"version": "0.0.0",
"private": true,
"scripts": {
"build": "rm -rf dist && rollup -c",
"build": "npm install --no-package-lock && rm -rf dist && rollup -c",
"start": "npm run build && npx http-server . -o"
},
"dependencies": {
"uuid": "file:../../.local/uuid"
"uuid": "file:../../.build/uuid.tgz"
},
"devDependencies": {
"@rollup/plugin-node-resolve": "^15.2.3",
-1
View File
@@ -1 +0,0 @@
dist/
File diff suppressed because it is too large Load Diff
+2 -2
View File
@@ -3,11 +3,11 @@
"version": "0.0.0",
"private": true,
"scripts": {
"build": "rm -rf dist && webpack",
"build": "npm install --no-package-lock && rm -rf dist && webpack",
"start": "npm run build && npx http-server . -o"
},
"dependencies": {
"uuid": "file:../../.local/uuid"
"uuid": "file:../../.build/uuid.tgz"
},
"devDependencies": {
"webpack": "5.93.0",
-91
View File
@@ -1,91 +0,0 @@
{
"name": "uuid-example-node-commonjs",
"version": "0.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "uuid-example-node-commonjs",
"version": "0.0.0",
"dependencies": {
"uuid": "file:../../.local/uuid"
}
},
"../../.local/uuid": {
"version": "10.0.0",
"funding": [
"https://github.com/sponsors/broofa",
"https://github.com/sponsors/ctavan"
],
"license": "MIT",
"bin": {
"uuid": "dist/esm/bin/uuid"
},
"devDependencies": {
"@babel/eslint-parser": "7.24.8",
"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",
"@eslint/js": "9.7.0",
"@types/eslint__js": "8.42.3",
"@wdio/browserstack-service": "8.39.0",
"@wdio/cli": "8.39.1",
"@wdio/jasmine-framework": "8.39.0",
"@wdio/local-runner": "8.39.0",
"@wdio/spec-reporter": "8.39.0",
"@wdio/static-server-service": "8.39.0",
"bundlewatch": "0.3.3",
"eslint": "9.7.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"globals": "15.8.0",
"husky": "9.1.1",
"jest": "29.7.0",
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
"typescript": "5.5.3",
"typescript-eslint": "8.0.0-alpha.30"
}
},
"node_modules/uuid": {
"resolved": "../../.local/uuid",
"link": true
}
},
"dependencies": {
"uuid": {
"version": "file:../../.local/uuid",
"requires": {
"@babel/eslint-parser": "7.24.8",
"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",
"@eslint/js": "9.7.0",
"@types/eslint__js": "8.42.3",
"@wdio/browserstack-service": "8.39.0",
"@wdio/cli": "8.39.1",
"@wdio/jasmine-framework": "8.39.0",
"@wdio/local-runner": "8.39.0",
"@wdio/spec-reporter": "8.39.0",
"@wdio/static-server-service": "8.39.0",
"bundlewatch": "0.3.3",
"eslint": "9.7.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"globals": "15.8.0",
"husky": "9.1.1",
"jest": "29.7.0",
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
"typescript": "5.5.3",
"typescript-eslint": "8.0.0-alpha.30"
}
}
}
}
+2 -1
View File
@@ -3,9 +3,10 @@
"version": "0.0.0",
"private": true,
"scripts": {
"pretest": "npm install --no-package-lock",
"test": "node example.js"
},
"dependencies": {
"uuid": "file:../../.local/uuid"
"uuid": "file:../../.build/uuid.tgz"
}
}
-91
View File
@@ -1,91 +0,0 @@
{
"name": "uuid-example-node-esmodules",
"version": "0.0.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "uuid-example-node-esmodules",
"version": "0.0.0",
"dependencies": {
"uuid": "file:../../.local/uuid"
}
},
"../../.local/uuid": {
"version": "10.0.0",
"funding": [
"https://github.com/sponsors/broofa",
"https://github.com/sponsors/ctavan"
],
"license": "MIT",
"bin": {
"uuid": "dist/esm/bin/uuid"
},
"devDependencies": {
"@babel/eslint-parser": "7.24.8",
"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",
"@eslint/js": "9.7.0",
"@types/eslint__js": "8.42.3",
"@wdio/browserstack-service": "8.39.0",
"@wdio/cli": "8.39.1",
"@wdio/jasmine-framework": "8.39.0",
"@wdio/local-runner": "8.39.0",
"@wdio/spec-reporter": "8.39.0",
"@wdio/static-server-service": "8.39.0",
"bundlewatch": "0.3.3",
"eslint": "9.7.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"globals": "15.8.0",
"husky": "9.1.1",
"jest": "29.7.0",
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
"typescript": "5.5.3",
"typescript-eslint": "8.0.0-alpha.30"
}
},
"node_modules/uuid": {
"resolved": "../../.local/uuid",
"link": true
}
},
"dependencies": {
"uuid": {
"version": "file:../../.local/uuid",
"requires": {
"@babel/eslint-parser": "7.24.8",
"@commitlint/cli": "19.3.0",
"@commitlint/config-conventional": "19.2.2",
"@eslint/js": "9.7.0",
"@types/eslint__js": "8.42.3",
"@wdio/browserstack-service": "8.39.0",
"@wdio/cli": "8.39.1",
"@wdio/jasmine-framework": "8.39.0",
"@wdio/local-runner": "8.39.0",
"@wdio/spec-reporter": "8.39.0",
"@wdio/static-server-service": "8.39.0",
"bundlewatch": "0.3.3",
"eslint": "9.7.0",
"eslint-config-prettier": "9.1.0",
"eslint-plugin-prettier": "5.2.1",
"globals": "15.8.0",
"husky": "9.1.1",
"jest": "29.7.0",
"lint-staged": "15.2.7",
"neostandard": "0.11.1",
"npm-run-all": "4.1.5",
"prettier": "3.3.3",
"runmd": "1.3.9",
"standard-version": "9.5.0",
"typescript": "5.5.3",
"typescript-eslint": "8.0.0-alpha.30"
}
}
}
}
+2 -1
View File
@@ -5,9 +5,10 @@
"scripts": {
"test:package": "( node --version | grep -vq 'v16' ) || ( node --experimental-json-modules package.mjs )",
"test:example": "node example.mjs",
"pretest": "npm install --no-package-lock",
"test": "npm-run-all test:*"
},
"dependencies": {
"uuid": "file:../../.local/uuid"
"uuid": "file:../../.build/uuid.tgz"
}
}
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -3,10 +3,11 @@
"version": "0.0.0",
"private": true,
"scripts": {
"pretest": "npm install --no-package-lock",
"test": "jest"
},
"dependencies": {
"uuid": "file:../../.local/uuid"
"uuid": "file:../../.build/uuid.tgz"
},
"devDependencies": {
"jest": "^29.7.0",
-1
View File
@@ -1 +0,0 @@
dist/
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -4,10 +4,11 @@
"private": true,
"scripts": {
"build": "rm -rf dist && webpack",
"pretest": "npm install --no-package-lock",
"test": "npm run build && node dist/v1.js && node dist/v4.js && node dist/v7.js && node dist/all.js"
},
"dependencies": {
"uuid": "file:../../.local/uuid"
"uuid": "file:../../.build/uuid.tgz"
},
"devDependencies": {
"webpack": "^5.74.0",
+9457 -1
View File
File diff suppressed because it is too large Load Diff
+10 -10
View File
@@ -87,26 +87,26 @@
"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",
"examples:browser:rollup:build": "cd examples/browser-rollup && npm install && npm run build",
"examples:browser:webpack:build": "cd examples/browser-webpack && npm install && npm run build",
"examples:node:commonjs:test": "cd examples/node-commonjs && npm install && npm test",
"examples:node:esmodules:test": "cd examples/node-esmodules && npm install && npm test",
"examples:node:jest:test": "cd examples/node-jest && npm install && npm test",
"examples:browser:rollup:build": "cd examples/browser-rollup && npm run build",
"examples:browser:webpack:build": "cd examples/browser-webpack && npm run build",
"examples:node:commonjs:test": "cd examples/node-commonjs && npm test",
"examples:node:esmodules:test": "cd examples/node-esmodules && npm test",
"examples:node:jest:test": "cd examples/node-jest && npm test",
"lint": "npm run eslint:check && npm run prettier:check",
"md": "runmd --watch --output=README.md README_js.md",
"prepack": "npm run build",
"prepack": "npm run build -- --no-pack",
"prepare": "husky",
"prepublishOnly": "npm run build",
"pretest:benchmark": "npm run build",
"pretest:browser": "./scripts/iodd && npm run build && npm-run-all --parallel examples:browser:**",
"pretest:browser": "./scripts/iodd && npm run build && npm-run-all examples:browser:**",
"pretest:node": "npm run build",
"pretest": "npm run build",
"prettier:check": "prettier --check .",
"prettier:fix": "prettier --write .",
"release": "standard-version --no-verify",
"test:benchmark": "cd examples/benchmark && HUSKY=0 npm install && npm test",
"test:benchmark": "cd examples/benchmark && npm test",
"test:browser": "wdio run ./wdio.conf.js",
"test:node": "npm-run-all --parallel examples:node:**",
"test:pack": "./scripts/testpack.sh",
"test:node": "npm-run-all examples:node:**",
"test:watch": "node --test --enable-source-maps --watch dist/esm/test/*.js",
"test": "node --test --enable-source-maps dist/esm/test/*.js"
},
+29 -15
View File
@@ -9,38 +9,40 @@
# Note: that the "preferred" build for testing (local and CI) is the ESM build,
# except where we specifically test the other builds
set -e # exit on error
# Change to project root
ROOT="$(pwd)/$(dirname "$0")/.."
cd "$ROOT" || exit 1
DIR="$ROOT/dist"
# Clean output dir
rm -rf "$DIR"
mkdir -p "$DIR"
# Prep TS output dir
DIST_DIR="$ROOT/dist"
rm -rf "$DIST_DIR"
mkdir -p "$DIST_DIR"
# Build each module type
for MODULE_TYPE in esm cjs; do
echo "Building ${MODULE_TYPE}"
DIST_DIR="$DIR/${MODULE_TYPE}"
BROWSER_DIR="$DIR/${MODULE_TYPE}-browser"
NODE_DIST_DIR="$DIST_DIR/${MODULE_TYPE}"
BROWSER_DIST_DIR="$DIST_DIR/${MODULE_TYPE}-browser"
tsc -p tsconfig.${MODULE_TYPE}.json
# Clone files for browser builds
cp -pr ${DIST_DIR} ${BROWSER_DIR}
cp -pr ${NODE_DIST_DIR} ${BROWSER_DIST_DIR}
# Remove browser files from non-browser builds
for FILE in ${DIST_DIR}/*-browser*;do
for FILE in ${NODE_DIST_DIR}/*-browser*;do
rm -f $FILE
done
# Move browser files into place for browser builds
(
# Temporarily cd into BROWSER_DIR to avoid having to deal with "-browser"
# appearing in both the dir name and file name of FILE's full path
cd ${BROWSER_DIR}
# 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}
for FILE in *-browser*;do
mv $FILE ${FILE/-browser/}
@@ -50,12 +52,24 @@ for MODULE_TYPE in esm cjs; do
# esm/cjs-specific logic
if [ "$MODULE_TYPE" = "esm" ]; then
# ESM: copy bin files to dist
cp -pr "$DIR/../src/bin" "$DIST_DIR"
cp -pr "$DIST_DIR/../src/bin" "$NODE_DIST_DIR"
else
# CJS: Add package.json that specifies type: commonjs
echo "{\"type\":\"commonjs\"}" > "$DIST_DIR/package.json"
echo "{\"type\":\"commonjs\"}" > "$BROWSER_DIR/package.json"
echo "{\"type\":\"commonjs\"}" > "$NODE_DIST_DIR/package.json"
echo "{\"type\":\"commonjs\"}" > "$BROWSER_DIST_DIR/package.json"
fi
done
if [ "${1-}" != "--no-pack" ]; then
# Prep tarball dir
BUILD_DIR="$ROOT/.build"
mkdir -p "$BUILD_DIR"
rm -rf "$BUILD_DIR/uuid-*.tgz"
# Create tarball for local installation (in tests and examples)
echo "Packing tarball"
npm pack --pack-destination "$BUILD_DIR" > /dev/null 2>&1
mv $BUILD_DIR/uuid-*.tgz $BUILD_DIR/uuid.tgz
fi
echo "-- fin --"
-33
View File
@@ -1,33 +0,0 @@
#!/bin/bash -eu
# cd to the root dir
ROOT="$(pwd)/$(dirname "$0")/.."
cd "$ROOT" || exit 1
TEST_DIR=$(mktemp -d)
mkdir -p ${TEST_DIR}
trap 'rm -rf $TEST_DIR' EXIT
# Create package tarball
npm pack --pack-destination=${TEST_DIR}
# Set up a test project in the test directory
pushd ${TEST_DIR}
npm init -y
cp ${ROOT}/examples/node-commonjs/example.js commonjs.js
cp ${ROOT}/examples/node-esmodules/example.mjs esmodules.mjs
cp ${ROOT}/examples/node-esmodules/package.mjs esmodules-package.mjs
# Install the tarball
npm install uuid*.tgz
# Verify scripts that depend on package work
node commonjs.js
node esmodules.mjs
# Support for json esm imports requires import assertions starting in Node.js v16.14.0 which were
# not supported in earlier versions. Therefore we restrict the ESM test to more recent versions of
# Node.js:
( node --version | grep -vq 'v16' ) || ( node --experimental-json-modules esmodules-package.mjs )