diff --git a/.babelrc b/.babelrc index 30c1213..4611fb7 100644 --- a/.babelrc +++ b/.babelrc @@ -1,21 +1,21 @@ { "sourceMaps": true, + "plugins": ["@babel/plugin-transform-runtime"], "presets": [ "@babel/typescript", [ "@babel/preset-env", { - "corejs": 3, - "loose": true, - "shippedProposals": true, "targets": { "browsers": "> 0.25%, not dead", "node": "9" }, - "useBuiltIns": "usage" + "loose": true, + "useBuiltIns": "usage", + "corejs": 2, + "shippedProposals": true }, "minify" ] - ], - "plugins": ["@babel/plugin-transform-runtime"] + ] } diff --git a/.eslintrc b/.eslintrc index 34a6e68..2883194 100644 --- a/.eslintrc +++ b/.eslintrc @@ -9,7 +9,6 @@ "plugin:@typescript-eslint/recommended", "airbnb-base", "airbnb-typescript/base", - "plugin:@typescript-eslint/recommended", "prettier" ], "parser": "@typescript-eslint/parser", @@ -25,7 +24,7 @@ "no-console": "warn", "no-await-in-loop": "off", "import/order": [ - "error", + "warn", { "groups": [ "builtin", diff --git a/.npm-upgrade.json b/.npm-upgrade.json new file mode 100644 index 0000000..cc31b6d --- /dev/null +++ b/.npm-upgrade.json @@ -0,0 +1,8 @@ +{ + "ignore": { + "core-js": { + "versions": ">=3", + "reason": "Using version 2 for compact output" + } + } +} diff --git a/package-lock.json b/package-lock.json index 2c90550..0e8e86b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,7 +26,7 @@ "@typescript-eslint/eslint-plugin": "^5.30.6", "@typescript-eslint/parser": "^5.30.6", "babel-jest": "^28.1.3", - "core-js": "^3.23.4", + "core-js": "^2.6.12", "eslint": "^8.19.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-config-airbnb-typescript": "^17.0.0", @@ -4450,15 +4450,12 @@ } }, "node_modules/core-js": { - "version": "3.23.4", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.23.4.tgz", - "integrity": "sha512-vjsKqRc1RyAJC3Ye2kYqgfdThb3zYnx9CrqoCcjMOENMtQPC7ZViBvlDxwYU/2z2NI/IPuiXw5mT4hWhddqjzQ==", + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", + "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", + "deprecated": "core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.", "dev": true, - "hasInstallScript": true, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/core-js" - } + "hasInstallScript": true }, "node_modules/core-js-compat": { "version": "3.22.5", @@ -14843,9 +14840,9 @@ } }, "core-js": { - "version": "3.23.4", - "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.23.4.tgz", - "integrity": "sha512-vjsKqRc1RyAJC3Ye2kYqgfdThb3zYnx9CrqoCcjMOENMtQPC7ZViBvlDxwYU/2z2NI/IPuiXw5mT4hWhddqjzQ==", + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", + "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", "dev": true }, "core-js-compat": { diff --git a/package.json b/package.json index 688f5b3..18dc32b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "yup-phone-lite", "version": "1.1.1", - "description": "Adds a phone number validation check to yup validator using libphonenumber-js.", + "description": "Adds a phone number validation check to yup using libphonenumber-js.", "license": "MIT", "author": "Chris Sandvik (https://github.com/csandman)", "repository": { @@ -54,7 +54,7 @@ "@typescript-eslint/eslint-plugin": "^5.30.6", "@typescript-eslint/parser": "^5.30.6", "babel-jest": "^28.1.3", - "core-js": "^3.23.4", + "core-js": "^2.6.12", "eslint": "^8.19.0", "eslint-config-airbnb-base": "^15.0.0", "eslint-config-airbnb-typescript": "^17.0.0", diff --git a/rollup.config.js b/rollup.config.js index a877473..e1867ed 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,6 +1,6 @@ import compiler from "@ampproject/rollup-plugin-closure-compiler"; import commonjs from "@rollup/plugin-commonjs"; -import { nodeResolve } from "@rollup/plugin-node-resolve"; +import resolve from "@rollup/plugin-node-resolve"; import analyze from "rollup-plugin-analyzer"; import filesize from "rollup-plugin-filesize"; import progress from "rollup-plugin-progress"; @@ -23,20 +23,27 @@ const webConfig = { progress(), filesize(), analyze(), - nodeResolve({ + resolve({ browser: true, - dedupe: ["yup"], }), // so Rollup can find `yup` commonjs({ - include: /node_modules/, + include: "node_modules/**", }), // so Rollup can convert `yup` to an ES module typescript({ transpiler: "babel", }), - compiler(), ], }; +// browser-friendly UMD build +const webMinConfig = Object.assign({}, webConfig, { + output: { + ...webConfig.output, + file: pkg.browser.replace(/(\.js)$/, ".min$1"), // yup-phone.umd.js → yup-phone.umd.min.js + }, + plugins: [...webConfig.plugins, compiler()], +}); + // CommonJS (for Node) and ES module (for bundlers) build. // (We could have three entries in the configuration array // instead of two, but it's quicker to generate multiple @@ -45,7 +52,7 @@ const webConfig = { // `file` and `format` for each target) const nodeConfig = { input: "src/yup-phone-lite.ts", - external: ["yup", "libphonenumber-js"], + external: ["yup"], output: [ { file: pkg.main, format: "cjs", sourcemap: true }, { file: pkg.module, format: "es", sourcemap: true }, @@ -63,4 +70,4 @@ const nodeConfig = { export default process.env.NODE_ENV === "test" ? nodeConfig - : [webConfig, nodeConfig]; + : [webConfig, webMinConfig, nodeConfig];