Skip to content

Commit 5648f8c

Browse files
authored
Merge pull request #3 from icd2k3/add-standalone-version
Adds a standalone build w/o scroll-into-view-if-needed
2 parents fb7cfcf + 1687fcd commit 5648f8c

File tree

4 files changed

+42
-24
lines changed

4 files changed

+42
-24
lines changed

README.md

+11
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ const MyComponent = () => (
2828
);
2929
```
3030

31+
## Standalone Version
32+
33+
The standalone version does _not_ come bundled with [scroll-into-view-if-needed](https://www.npmjs.com/package/scroll-into-view-if-needed). Use this version if you'd like to maintain your own dependency for scroll-into-view-if-needed.
34+
35+
ES version:
36+
`import ScrollIntoViewIfNeeded from 'react-scroll-into-view-if-needed/dist/es/standalone.js'`
37+
38+
UMD version:
39+
`import ScrollIntoViewIfNeeded from 'react-scroll-into-view-if-needed/dist/umd/standalone.js'`
40+
3141
## Optional Props
3242

3343
#### active
@@ -47,3 +57,4 @@ Set the wrapper component type. For example, this could also be `'footer'`, `'bu
4757
> Default: `{ duration: 250, easing: 'easeOut' }`
4858
4959
The `options` prop simply passes options to `scroll-into-view-if-needed`. See all the possible options in their [API documentation](https://www.npmjs.com/package/scroll-into-view-if-needed#api).
60+

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-scroll-into-view-if-needed",
3-
"version": "1.0.1",
3+
"version": "1.0.2",
44
"description": "A thin component wrapper around scroll-into-view-if-needed",
55
"main": "dist/umd/index.js",
66
"module": "dist/es/index.js",
@@ -24,6 +24,7 @@
2424
"babel-preset-react": "^6.24.1",
2525
"babel-preset-stage-2": "^6.24.1",
2626
"coveralls": "^3.0.0",
27+
"cross-env": "^5.1.4",
2728
"enzyme": "^3.3.0",
2829
"enzyme-adapter-react-16": "^1.1.1",
2930
"eslint": "^4.19.1",
@@ -41,7 +42,7 @@
4142
"rollup-plugin-node-resolve": "^3.3.0"
4243
},
4344
"scripts": {
44-
"build": "rollup -c",
45+
"build": "rollup -c && cross-env BUILD_TYPE=standalone rollup -c",
4546
"lint": "eslint ./src/**",
4647
"prepublishOnly": "yarn build",
4748
"test": "jest",

rollup.config.js

+20-21
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,26 @@ import resolve from 'rollup-plugin-node-resolve';
44

55
const pkg = require('./package.json');
66

7-
const external = Object.keys(pkg.peerDependencies);
8-
9-
const globals = {
10-
react: 'React',
7+
const IS_STANDALONE_BUILD = process.env.BUILD_TYPE === 'standalone';
8+
const name = 'react-scroll-into-view-if-needed';
9+
const external = Object.keys(pkg.peerDependencies)
10+
.concat(IS_STANDALONE_BUILD ? 'scroll-into-view-if-needed' : []);
11+
const globals = { react: 'React' };
12+
const rootOutputProps = {
13+
exports: 'named',
14+
globals,
15+
name,
16+
sourcemap: true,
1117
};
18+
const output = IS_STANDALONE_BUILD
19+
? [
20+
{ ...rootOutputProps, file: 'dist/umd/standalone.js', format: 'umd' },
21+
{ ...rootOutputProps, file: 'dist/es/standalone.js', format: 'es' },
22+
]
23+
: [
24+
{ ...rootOutputProps, file: pkg.main, format: 'umd' },
25+
{ ...rootOutputProps, file: pkg.module, format: 'es' },
26+
];
1227

1328
const config = {
1429
input: 'src/index.js',
@@ -25,23 +40,7 @@ const config = {
2540
commonjs(),
2641
],
2742
external,
28-
output: [
29-
{
30-
exports: 'named',
31-
file: pkg.main,
32-
format: 'umd',
33-
globals,
34-
name: 'react-scroll-into-view-if-needed',
35-
sourcemap: true,
36-
},
37-
{
38-
exports: 'named',
39-
file: pkg.module,
40-
format: 'es',
41-
globals,
42-
sourcemap: true,
43-
},
44-
],
43+
output,
4544
};
4645

4746
export default config;

yarn.lock

+8-1
Original file line numberDiff line numberDiff line change
@@ -1397,6 +1397,13 @@ coveralls@^3.0.0:
13971397
minimist "^1.2.0"
13981398
request "^2.79.0"
13991399

1400+
cross-env@^5.1.4:
1401+
version "5.1.4"
1402+
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.1.4.tgz#f61c14291f7cc653bb86457002ea80a04699d022"
1403+
dependencies:
1404+
cross-spawn "^5.1.0"
1405+
is-windows "^1.0.0"
1406+
14001407
cross-spawn@^5.0.1, cross-spawn@^5.1.0:
14011408
version "5.1.0"
14021409
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
@@ -2711,7 +2718,7 @@ is-utf8@^0.2.0:
27112718
version "0.2.1"
27122719
resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72"
27132720

2714-
is-windows@^1.0.2:
2721+
is-windows@^1.0.0, is-windows@^1.0.2:
27152722
version "1.0.2"
27162723
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d"
27172724

0 commit comments

Comments
 (0)