forked from floating-ui/floating-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING CHANGE: You have to include `popper-utils.js` before `popper.js` if you want to access `Popper.Utils` methods. This is needed to reduce the size of the `popper.js` bundle from 6.2kb to 5.83kb! This commit also changes the way Popper is built, making it easier to maintain and use. prettier-eslint has been fixed as well
- Loading branch information
Federico Zivolo
committed
Apr 17, 2017
1 parent
6fc4cf2
commit f6c7e75
Showing
21 changed files
with
265 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
const { exec, execSync } = require('child_process'); | ||
const { waterfall } = require('async'); | ||
const { argv } = require('yargs'); | ||
const colors = require('colors'); | ||
const { build } = argv; | ||
|
||
const rollup = 'rollup -c ./scripts/rollup.config.js'; | ||
const minify = 'node ./scripts/minify.js'; | ||
const gzipped = '$(npm bin)/gzipped'; | ||
|
||
console.log(colors.green(`⚙️ Compiling target '${build}'...`)); | ||
const next = done => | ||
exec(`${rollup} --environment BUILD:${build}`, error => { | ||
if (error) { | ||
console.error(`${build}: ${error}`); | ||
} | ||
exec(`${minify} -i ./dist/${build}.js -o ./dist/${build}.min.js`, error => { | ||
if (error) { | ||
console.error(`${build}.minify: ${error}`); | ||
} | ||
console.info( | ||
colors.yellow(`${build}`), | ||
`\n${execSync(`${gzipped} ./dist/${build}.js`).toString()}` | ||
); | ||
console.info( | ||
colors.yellow(`${build}.min`), | ||
`\n${execSync(`${gzipped} ./dist/${build}.min.js`).toString()}` | ||
); | ||
done(); | ||
}); | ||
}); | ||
|
||
const es5 = done => | ||
exec(`${rollup} --environment BUILD:${build},ES5`, error => { | ||
if (error) { | ||
console.error(`${build}.es5: ${error}`); | ||
} | ||
exec( | ||
`${minify} -i ./dist/${build}.es5.js -o ./dist/${build}.es5.min.js`, | ||
error => { | ||
if (error) { | ||
console.error(`${build}.es5.minify: ${error}`); | ||
} | ||
console.info( | ||
colors.yellow(`${build}.es5`), | ||
`\n${execSync(`${gzipped} ./dist/${build}.es5.js`).toString()}` | ||
); | ||
console.info( | ||
colors.yellow(`${build}.es5.min`), | ||
`\n${execSync(`${gzipped} ./dist/${build}.es5.min.js`).toString()}` | ||
); | ||
done(); | ||
} | ||
); | ||
}); | ||
|
||
waterfall([next, es5], error => { | ||
if (error) { | ||
console.error(`${build}: ${error}`); | ||
} | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import babel from 'rollup-plugin-babel'; | ||
|
||
const ROOT = `${__dirname}/..`; | ||
const ES5 = process.env.ES5; | ||
const BUILD = process.env.BUILD; | ||
|
||
const babelConfig = ES5 | ||
? { | ||
presets: [['es2015', { modules: false }], 'stage-2'], | ||
} | ||
: {}; | ||
const es5Ext = ES5 ? '.es5' : ''; | ||
|
||
let entry, dest, moduleName, sourceMapFile; | ||
switch (BUILD) { | ||
case 'popper': | ||
moduleName = 'Popper'; | ||
entry = `${ROOT}/src/popper/index.js`; | ||
dest = `${ROOT}/dist/popper${es5Ext}.js`; | ||
sourceMapFile = `${ROOT}/dist/popper${es5Ext}.js.map`; | ||
break; | ||
case 'popper-utils': | ||
moduleName = 'PopperUtils'; | ||
entry = `${ROOT}/src/popper/utils/index.js`; | ||
dest = `${ROOT}/dist/popper-utils${es5Ext}.js`; | ||
sourceMapFile = `${ROOT}/dist/popper-utils${es5Ext}.js.map`; | ||
break; | ||
case 'tooltip': | ||
moduleName = 'Popper'; | ||
entry = `${ROOT}/src/tooltip/index.js`; | ||
dest = `${ROOT}/dist/tooltip${es5Ext}.js`; | ||
sourceMapFile = `${ROOT}/dist/tooltip${es5Ext}.js.map`; | ||
break; | ||
} | ||
|
||
export default { | ||
entry, | ||
dest, | ||
moduleName, | ||
format: 'umd', | ||
sourceMap: true, | ||
sourceMapFile, | ||
plugins: [babel(babelConfig)], | ||
}; |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
/** | ||
* Given the popper offsets, generate an output similar to getBoundingClientRect | ||
* Given element offsets, generate an output similar to getBoundingClientRect | ||
* @method | ||
* @memberof Popper.Utils | ||
* @argument {Object} popperOffsets | ||
* @argument {Object} offsets | ||
* @returns {Object} ClientRect like output | ||
*/ | ||
export default function getClientRect(popperOffsets) { | ||
export default function getClientRect(offsets) { | ||
return { | ||
...popperOffsets, | ||
right: popperOffsets.left + popperOffsets.width, | ||
bottom: popperOffsets.top + popperOffsets.height, | ||
...offsets, | ||
right: offsets.left + offsets.width, | ||
bottom: offsets.top + offsets.height, | ||
}; | ||
} |
Oops, something went wrong.