From 4603f2295b18e50d83784175c3a67dd5021b0cc1 Mon Sep 17 00:00:00 2001 From: Vikram Subramanian Date: Wed, 29 Apr 2020 19:29:17 -0700 Subject: [PATCH] Add test for Node ESM conditional exports --- .gitignore | 1 + package.json | 3 ++- test/fixtures/esm/index.js | 5 +++++ test/fixtures/esm/package.json | 10 ++++++++++ 4 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 test/fixtures/esm/index.js create mode 100644 test/fixtures/esm/package.json diff --git a/.gitignore b/.gitignore index a32229b..fbca3fd 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ package-lock.json dist mini yarn.lock +htm.tgz diff --git a/package.json b/package.json index 6bfcc54..60b0a31 100644 --- a/package.json +++ b/package.json @@ -48,8 +48,9 @@ "build:babel": "cd packages/babel-plugin-htm && npm run build", "build:babel-transform-jsx": "cd packages/babel-plugin-transform-jsx-to-htm && npm run build", "build:mjsalias": "cp dist/htm.module.js dist/htm.mjs && cp mini/index.module.js mini/index.mjs && cp preact/index.module.js preact/index.mjs && cp preact/standalone.module.js preact/standalone.mjs && cp react/index.module.js react/index.mjs", - "test": "eslint src/**/*.mjs test/**/*.mjs && npm run build && jest test", + "test": "eslint src/**/*.mjs test/**/*.mjs --ignore-path .gitignore && npm run build && jest test", "test:perf": "v8 test/__perftest.mjs", + "test:dist": "npm pack && mv htm*.tgz test/fixtures/esm/htm.tgz && cd test/fixtures/esm && npm install && node index.js", "release": "npm t && git commit -am \"$npm_package_version\" && git tag $npm_package_version && git push && git push --tags && npm publish" }, "files": [ diff --git a/test/fixtures/esm/index.js b/test/fixtures/esm/index.js new file mode 100644 index 0000000..317ebc7 --- /dev/null +++ b/test/fixtures/esm/index.js @@ -0,0 +1,5 @@ +import "htm"; +import "htm/preact"; +import "htm/preact/standalone"; +// TODOD: Enable once react distro is ESM compatible. +// import "htm/react"; diff --git a/test/fixtures/esm/package.json b/test/fixtures/esm/package.json new file mode 100644 index 0000000..5f7e92b --- /dev/null +++ b/test/fixtures/esm/package.json @@ -0,0 +1,10 @@ +{ + "name": "htm_dist_test", + "type": "module", + "private": true, + "description": "A package to test importing htm as ES modules in Node", + "dependencies": { + "htm": "file:htm.tgz", + "preact": "^10.4.1" + } +}