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

chore: run node-esmodule package.json test only in latest node LTS #621

Merged
merged 6 commits into from
Mar 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added a
Empty file.
4 changes: 0 additions & 4 deletions examples/node-esmodules/example.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
version as uuidVersion,
} from 'uuid';
import * as uuid from 'uuid';
import pkg from 'uuid/package.json';

console.log('uuidv1()', uuidv1());

Expand Down Expand Up @@ -65,6 +64,3 @@ console.log('uuid.parse()', uuid.parse(MY_NAMESPACE));
console.log('uuid.stringify()', uuid.stringify(uuid.parse(MY_NAMESPACE)));
console.log('uuid.validate()', uuid.validate(MY_NAMESPACE));
console.log('uuid.version()', uuid.version(MY_NAMESPACE));

// Some tools like react-native need to introspect the package.json file
console.log('pkg.name', pkg.name);
4 changes: 3 additions & 1 deletion examples/node-esmodules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
"version": "0.0.0",
"private": true,
"scripts": {
"test": "node --experimental-modules --experimental-json-modules example.mjs"
"test:package": "( node --version | grep -vq 'v16' ) || ( node --experimental-json-modules package.mjs )",
"test:example": "node example.mjs",
"test": "npm-run-all test:*"
},
"dependencies": {
"uuid": "file:../../.local/uuid"
Expand Down
4 changes: 4 additions & 0 deletions examples/node-esmodules/package.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import pkg from 'uuid/package.json' assert { type: 'json' };

// Some tools like react-native need to introspect the package.json file
console.log('pkg.name', pkg.name);
8 changes: 7 additions & 1 deletion scripts/testpack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ mkdir -p ../test-pack

cp examples/node-commonjs/example.js ../test-pack/commonjs.js
cp examples/node-esmodules/example.mjs ../test-pack/esmodules.mjs
cp examples/node-esmodules/package.mjs ../test-pack/esmodules-package.mjs

cd ../test-pack

Expand All @@ -18,4 +19,9 @@ npm init -y
npm install ../uuid/uuid-*.tgz

node commonjs.js
node --experimental-json-modules esmodules.mjs
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 )