Skip to content

Commit b6b21c6

Browse files
committed
Resolve crypto API properly in node environments
Addresses #82 and #84
1 parent f1fbc54 commit b6b21c6

File tree

3 files changed

+51
-33
lines changed

3 files changed

+51
-33
lines changed

gulpfile.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,14 @@ gulp.task('test', ['test-script-format', 'test-mocha']);
4040

4141
gulp.task('build-script', ['test'], () => (
4242
gulp.src(['./src/index.js'])
43-
.pipe(webpackStream(webpackConfig, webpack))
43+
.pipe(webpackStream(webpackConfig('node'), webpack))
44+
.pipe(header(banner, { pkg }))
45+
.pipe(gulp.dest('./lib/'))
46+
));
47+
48+
gulp.task('build-script-web', ['test'], () => (
49+
gulp.src(['./src/index.js'])
50+
.pipe(webpackStream(webpackConfig('web'), webpack))
4451
.pipe(header(banner, { pkg }))
4552
.pipe(gulp.dest('./lib/'))
4653
));
@@ -58,7 +65,7 @@ gulp.task('build-style', () => (
5865
.pipe(gulp.dest('./lib'))
5966
));
6067

61-
gulp.task('build', ['build-script', 'build-style']);
68+
gulp.task('build', ['build-script', 'build-script-web', 'build-style']);
6269

6370
gulp.task('build-examples-style', () => (
6471
gulp.src('./examples/src/scss/**/*.scss')

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-checkbox-tree",
3-
"version": "1.2.3",
3+
"version": "1.2.4-rc.0",
44
"description": "A simple and elegant checkbox tree for React.",
55
"author": "Jake Zatecky",
66
"license": "MIT",
@@ -16,6 +16,7 @@
1616
"homepage": "https://jakezatecky.github.io/react-checkbox-tree",
1717
"bugs": "https://github.com/jakezatecky/react-checkbox-tree/issues",
1818
"main": "lib/index.js",
19+
"browser": "lib/index.browser.js",
1920
"scripts": {
2021
"build": "gulp build",
2122
"examples": "gulp examples",

webpack.config.js

Lines changed: 40 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,45 @@
1-
module.exports = {
2-
mode: 'production',
3-
output: {
4-
filename: 'index.js',
5-
libraryTarget: 'umd',
6-
library: 'ReactCheckboxTree',
7-
},
8-
externals: [
9-
{
10-
react: {
11-
root: 'React',
12-
commonjs2: 'react',
13-
commonjs: 'react',
14-
amd: 'react',
15-
},
1+
function makeConfig(target) {
2+
const fileMap = {
3+
node: 'index.js',
4+
web: 'index.browser.js',
5+
};
6+
7+
return {
8+
mode: 'production',
9+
target,
10+
output: {
11+
filename: fileMap[target],
12+
libraryTarget: 'umd',
13+
library: 'ReactCheckboxTree',
1614
},
17-
{
18-
'react-dom': {
19-
root: 'ReactDOM',
20-
commonjs2: 'react-dom',
21-
commonjs: 'react-dom',
22-
amd: 'react-dom',
15+
externals: [
16+
{
17+
react: {
18+
root: 'React',
19+
commonjs2: 'react',
20+
commonjs: 'react',
21+
amd: 'react',
22+
},
2323
},
24-
},
25-
],
26-
module: {
27-
rules: [
2824
{
29-
test: /\.js?$/,
30-
exclude: /(node_modules|bower_components|vender_modules)/,
31-
loader: 'babel-loader',
25+
'react-dom': {
26+
root: 'ReactDOM',
27+
commonjs2: 'react-dom',
28+
commonjs: 'react-dom',
29+
amd: 'react-dom',
30+
},
3231
},
3332
],
34-
},
35-
};
33+
module: {
34+
rules: [
35+
{
36+
test: /\.js?$/,
37+
exclude: /(node_modules|bower_components|vender_modules)/,
38+
loader: 'babel-loader',
39+
},
40+
],
41+
},
42+
};
43+
}
44+
45+
module.exports = makeConfig;

0 commit comments

Comments
 (0)