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

fix: export package.json required by react-native and bundlers #449

Merged
merged 1 commit into from
May 20, 2020
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
4 changes: 4 additions & 0 deletions examples/node-commonjs/example.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,7 @@ 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 tools like react-native need to introspect the package.json file
const pkg = require('uuid/package.json');
console.log('pkg.name', pkg.name);
4 changes: 4 additions & 0 deletions examples/node-esmodules/example.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { v1 as uuidv1, v4 as uuidv4, v3 as uuidv3, v5 as uuidv5 } from 'uuid';
import * as uuid from 'uuid';
import pkg from 'uuid/package.json';

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

Expand Down Expand Up @@ -41,3 +42,6 @@ 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 tools like react-native need to introspect the package.json file
console.log('pkg.name', pkg.name);
2 changes: 1 addition & 1 deletion examples/node-esmodules/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"private": true,
"scripts": {
"test": "node --experimental-modules example.mjs"
"test": "node --experimental-modules --experimental-json-modules example.mjs"
},
"dependencies": {
"uuid": "file:../../.local"
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@
"sideEffects": false,
"main": "./dist/index.js",
"exports": {
"require": "./dist/index.js",
"import": "./wrapper.mjs"
"./package.json": "./package.json",
".": {
"require": "./dist/index.js",
"import": "./wrapper.mjs"
}
},
"module": "./dist/esm-node/index.js",
"browser": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/testpack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ npm init -y
npm install ../uuid/uuid-*.tgz

node commonjs.js
node esmodules.mjs
node --experimental-json-modules esmodules.mjs