From 0021db9acebc16b454349a356b755237bb7e8978 Mon Sep 17 00:00:00 2001 From: Nico Rehwaldt Date: Wed, 10 Mar 2021 12:38:56 +0100 Subject: [PATCH] test: verify tree-shaking works --- .eslintignore | 1 + .gitignore | 3 +- package-lock.json | 53 ++++++++++++++++++++++++++++++++++ package.json | 8 ++++- test/bundling/index.js | 7 +++++ test/bundling/rollup.config.js | 13 +++++++++ 6 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 test/bundling/index.js create mode 100644 test/bundling/rollup.config.js diff --git a/.eslintignore b/.eslintignore index 53c37a1..25843ad 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1 +1,2 @@ +test/bundling/bundled.js dist \ No newline at end of file diff --git a/.gitignore b/.gitignore index 76add87..648976f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ node_modules -dist \ No newline at end of file +dist +test/bundling/bundled.js diff --git a/package-lock.json b/package-lock.json index 94cfbae..a0f844e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1668,6 +1668,32 @@ } } }, + "@rollup/plugin-node-resolve": { + "version": "11.2.0", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-11.2.0.tgz", + "integrity": "sha512-qHjNIKYt5pCcn+5RUBQxK8krhRvf1HnyVgUCcFFcweDS7fhkOLZeYh0mhHK6Ery8/bb9tvN/ubPzmfF0qjDCTA==", + "dev": true, + "requires": { + "@rollup/pluginutils": "^3.1.0", + "@types/resolve": "1.17.1", + "builtin-modules": "^3.1.0", + "deepmerge": "^4.2.2", + "is-module": "^1.0.0", + "resolve": "^1.19.0" + }, + "dependencies": { + "resolve": { + "version": "1.20.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.20.0.tgz", + "integrity": "sha512-wENBPt4ySzg4ybFQW2TT1zMQucPK95HSh/nq2CFTZVOGut2+pQvSsgtda4d26YrYcr067wjbmzOG8byDPBX63A==", + "dev": true, + "requires": { + "is-core-module": "^2.2.0", + "path-parse": "^1.0.6" + } + } + } + }, "@rollup/pluginutils": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", @@ -1734,6 +1760,15 @@ "integrity": "sha512-oJqcTrgPUF29oUP8AsUqbXGJNuPutsetaa9kTQAQce5Lx5dTYWV02ScBiT/k1BX/Z7pKeqedmvp39Wu4zR7N7g==", "dev": true }, + "@types/resolve": { + "version": "1.17.1", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.17.1.tgz", + "integrity": "sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@ungap/promise-all-settled": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", @@ -2449,6 +2484,12 @@ "integrity": "sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A==", "dev": true }, + "builtin-modules": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.2.0.tgz", + "integrity": "sha512-lGzLKcioL90C7wMczpkY0n/oART3MbBa8R9OFGE1rJxoVI86u4WAGfEk8Wjv10eKSyTHVGkSo3bvBylCEtk7LA==", + "dev": true + }, "bundlesize": { "version": "0.18.1", "resolved": "https://registry.npmjs.org/bundlesize/-/bundlesize-0.18.1.tgz", @@ -2905,6 +2946,12 @@ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, + "deepmerge": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/deepmerge/-/deepmerge-4.2.2.tgz", + "integrity": "sha512-FJ3UgI4gIl+PHZm53knsuSFpE+nESMr7M4v9QcgB7S63Kj/6WqMiFQJpBBYz1Pt+66bZpP3Q7Lye0Oo9MPKEdg==", + "dev": true + }, "define-properties": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", @@ -4178,6 +4225,12 @@ "is-extglob": "^1.0.0" } }, + "is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha1-Mlj7afeMFNW4FdZkM2tM/7ZEFZE=", + "dev": true + }, "is-negative-zero": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.1.tgz", diff --git a/package.json b/package.json index a66d58e..3cac36d 100644 --- a/package.json +++ b/package.json @@ -10,11 +10,12 @@ "bundle": "rollup -c", "bundle:checksize": "bundlesize", "copy": "cpx -v lib/*.d.ts dist", - "distro": "run-s copy bundle test:integration bundle:checksize", + "distro": "run-s copy bundle test:integration test:bundle bundle:checksize", "dev": "npm test -- --watch", "lint": "eslint .", "prepublishOnly": "run-s distro", "test": "mocha -r @babel/register -r source-map-support/register --full-trace test/*.spec.js", + "test:bundle": "rollup -c test/bundling/rollup.config.js", "test:integration": "mocha --full-trace test/integration/*.spec.js" }, "repository": { @@ -40,6 +41,7 @@ "@babel/preset-env": "^7.13.10", "@babel/register": "^7.13.8", "@rollup/plugin-babel": "^5.3.0", + "@rollup/plugin-node-resolve": "^11.2.0", "bundlesize": "^0.18.1", "chai": "^4.3.3", "cpx": "^1.5.0", @@ -57,6 +59,10 @@ { "path": "./dist/min-dash.min.js", "maxSize": "2 kB" + }, + { + "path": "./test/bundling/bundled.js", + "maxSize": "300 B" } ] } diff --git a/test/bundling/index.js b/test/bundling/index.js new file mode 100644 index 0000000..7128315 --- /dev/null +++ b/test/bundling/index.js @@ -0,0 +1,7 @@ +import { + has +} from '../..'; + +export function foo(a, b) { + return has(a, b); +} \ No newline at end of file diff --git a/test/bundling/rollup.config.js b/test/bundling/rollup.config.js new file mode 100644 index 0000000..972c87f --- /dev/null +++ b/test/bundling/rollup.config.js @@ -0,0 +1,13 @@ +import resolve from '@rollup/plugin-node-resolve'; + +export default [ + { + input: 'test/bundling/index.js', + output: [ + { file: 'test/bundling/bundled.js', format: 'es' } + ], + plugins: [ + resolve() + ] + } +]; \ No newline at end of file