From 281e6a1a96d65dbc52e0068700ba89d2d08d0317 Mon Sep 17 00:00:00 2001 From: Julian Krispel Date: Thu, 13 Sep 2018 12:27:21 +0100 Subject: [PATCH] move lib to src/lib and compile src/lib to cjs, add invariant and use that instead of fbjs update rollup config to include lib folder compilation --- .gitignore | 1 + .npmignore | 2 + package.json | 6 ++- rollup.config.js | 21 +++++++++- src/getVisibleSelectionRect.js | 2 +- {lib => src/lib}/placeRightBelow.js | 0 yarn.lock | 65 +++++++++++++++++++++++++++-- 7 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 .npmignore rename {lib => src/lib}/placeRightBelow.js (100%) diff --git a/.gitignore b/.gitignore index 61305f8..f245b59 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ node_modules # builds build +./lib dist # misc diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..adc5e2f --- /dev/null +++ b/.npmignore @@ -0,0 +1,2 @@ +example +src diff --git a/package.json b/package.json index 2d51776..6686676 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "react-text-selection-popover", - "version": "1.1.0", - "description": "", + "version": "1.1.1", + "description": "A popover component positioned according to the current selection in a contenteditable element", "author": "juliankrispel", "license": "MIT", "repository": "juliankrispel/react-text-selection-popover", @@ -28,6 +28,7 @@ ] }, "dependencies": { + "invariant": "^2.2.4", "lodash.debounce": "^4.0.8", "react-event-listener": "^0.6.1", "react-measure": "^2.1.2", @@ -59,6 +60,7 @@ "eslint-plugin-standard": "^3.0.1", "flow-bin": "^0.76.0", "gh-pages": "^1.1.0", + "globby": "^8.0.1", "react": "^16.2.0", "react-dom": "^16.2.0", "react-scripts": "^1.1.1", diff --git a/rollup.config.js b/rollup.config.js index 5d25cc8..14773eb 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -4,15 +4,17 @@ import external from "rollup-plugin-peer-deps-external"; import postcss from "rollup-plugin-postcss"; import resolve from "rollup-plugin-node-resolve"; import url from "rollup-plugin-url"; +import globby from 'globby' import pkg from "./package.json"; -export default { +const defaultConf = { input: 'src/index.js', external: [ 'react-measure', 'lodash.debounce', 'react', + 'invariant', 'react-dom', 'prop-types', 'draft-js/lib/getVisibleSelectionRect', @@ -41,4 +43,19 @@ export default { resolve(), commonjs() ] -}; +} + +export default [ + defaultConf, + ...globby.sync('./src/lib/*.js') + .map(filePath => ({ + ...defaultConf, + input: filePath, + output: [ + { + file: filePath.replace('src\/', ''), + format: 'cjs' + } + ], + })) +]; diff --git a/src/getVisibleSelectionRect.js b/src/getVisibleSelectionRect.js index 965e46a..9aeb0aa 100644 --- a/src/getVisibleSelectionRect.js +++ b/src/getVisibleSelectionRect.js @@ -9,7 +9,7 @@ * of patent rights can be found in the PATENTS file in the same directory. * */ -import invariant from "fbjs/lib/invariant"; +import invariant from "invariant"; var isChrome = /chrome/gi.test(window.navigator.userAgent); diff --git a/lib/placeRightBelow.js b/src/lib/placeRightBelow.js similarity index 100% rename from lib/placeRightBelow.js rename to src/lib/placeRightBelow.js diff --git a/yarn.lock b/yarn.lock index 62277f5..a976bc7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -84,6 +84,17 @@ lodash "^4.2.0" to-fast-properties "^2.0.0" +"@mrmlnc/readdir-enhanced@^2.2.1": + version "2.2.1" + resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde" + dependencies: + call-me-maybe "^1.0.1" + glob-to-regexp "^0.3.0" + +"@nodelib/fs.stat@^1.0.1": + version "1.1.2" + resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-1.1.2.tgz#54c5a964462be3d4d78af631363c18d6fa91ac26" + "@vue/component-compiler-utils@^1.0.0": version "1.3.1" resolved "https://registry.yarnpkg.com/@vue/component-compiler-utils/-/component-compiler-utils-1.3.1.tgz#686f0b913d59590ae327b2a1cb4b6d9b931bbe0e" @@ -1541,6 +1552,10 @@ cache-base@^1.0.1: union-value "^1.0.0" unset-value "^1.0.0" +call-me-maybe@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/call-me-maybe/-/call-me-maybe-1.0.1.tgz#26d208ea89e37b5cbde60250a15f031c16a4d66b" + caller-path@^0.1.0: version "0.1.0" resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f" @@ -2317,6 +2332,13 @@ diffie-hellman@^5.0.0: miller-rabin "^4.0.0" randombytes "^2.0.0" +dir-glob@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-2.0.0.tgz#0b205d2b6aef98238ca286598a8204d29d0a0034" + dependencies: + arrify "^1.0.1" + path-type "^3.0.0" + dns-equal@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/dns-equal/-/dns-equal-1.0.0.tgz#b39e7f1da6eb0a75ba9c17324b34753c47e0654d" @@ -3058,6 +3080,17 @@ fast-deep-equal@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz#7b05218ddf9667bf7f370bf7fdb2cb15fdd0aa49" +fast-glob@^2.0.2: + version "2.2.2" + resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-2.2.2.tgz#71723338ac9b4e0e2fff1d6748a2a13d5ed352bf" + dependencies: + "@mrmlnc/readdir-enhanced" "^2.2.1" + "@nodelib/fs.stat" "^1.0.1" + glob-parent "^3.1.0" + is-glob "^4.0.0" + merge2 "^1.2.1" + micromatch "^3.1.10" + fast-json-stable-stringify@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.0.0.tgz#d5142c0caee6b1189f87d3a76111064f86c8bbf2" @@ -3399,6 +3432,10 @@ glob-parent@^3.1.0: is-glob "^3.1.0" path-dirname "^1.0.0" +glob-to-regexp@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/glob-to-regexp/-/glob-to-regexp-0.3.0.tgz#8c5a1494d2066c570cc3bfe4496175acc4d502ab" + glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2: version "7.1.3" resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.3.tgz#3960832d3f1574108342dafd3a67b332c0969df1" @@ -3463,6 +3500,18 @@ globby@^6.1.0: pify "^2.0.0" pinkie-promise "^2.0.0" +globby@^8.0.1: + version "8.0.1" + resolved "https://registry.yarnpkg.com/globby/-/globby-8.0.1.tgz#b5ad48b8aa80b35b814fc1281ecc851f1d2b5b50" + dependencies: + array-union "^1.0.1" + dir-glob "^2.0.0" + fast-glob "^2.0.2" + glob "^7.1.2" + ignore "^3.3.5" + pify "^3.0.0" + slash "^1.0.0" + got@^6.7.1: version "6.7.1" resolved "http://registry.npmjs.org/got/-/got-6.7.1.tgz#240cd05785a9a18e561dc1b44b41c763ef1e8db0" @@ -3773,7 +3822,7 @@ ignore-walk@^3.0.1: dependencies: minimatch "^3.0.4" -ignore@^3.3.3, ignore@^3.3.6: +ignore@^3.3.3, ignore@^3.3.5, ignore@^3.3.6: version "3.3.10" resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.10.tgz#0a97fb876986e8081c631160f8f9f389157f0043" @@ -3866,7 +3915,7 @@ interpret@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.1.0.tgz#7ed1b1410c6a0e0f78cf95d3b8440c63f78b8614" -invariant@^2.2.0, invariant@^2.2.2: +invariant@^2.2.0, invariant@^2.2.2, invariant@^2.2.4: version "2.2.4" resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" dependencies: @@ -4879,6 +4928,10 @@ merge-source-map@^1.1.0: dependencies: source-map "^0.6.1" +merge2@^1.2.1: + version "1.2.2" + resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.2.2.tgz#03212e3da8d86c4d8523cebd6318193414f94e34" + merge@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/merge/-/merge-1.2.0.tgz#7531e39d4949c281a66b8c5a6e0265e8b05894da" @@ -4905,7 +4958,7 @@ micromatch@^2.1.5, micromatch@^2.3.11: parse-glob "^3.0.4" regex-cache "^0.4.2" -micromatch@^3.1.4: +micromatch@^3.1.10, micromatch@^3.1.4: version "3.1.10" resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" dependencies: @@ -5510,6 +5563,12 @@ path-type@^2.0.0: dependencies: pify "^2.0.0" +path-type@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f" + dependencies: + pify "^3.0.0" + pbkdf2@^3.0.3: version "3.0.16" resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.16.tgz#7404208ec6b01b62d85bf83853a8064f8d9c2a5c"