Skip to content

Commit cfbbfe4

Browse files
author
vvo
committed
feat(build): allow building React based custom widgets
fixes #373 This is a try at it, not sure this is sufficient
1 parent 0d95b55 commit cfbbfe4

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "instantsearch.js",
33
"version": "0.8.0",
44
"description": "instantsearch.js is a library of widgets to build high performance instant search experiences using Algolia",
5-
"main": "dist/instantsearch.js",
5+
"main": "dist/instantsearch.module.js",
66
"author": "Algolia <support@algolia.com>",
77
"scripts": {
88
"build": "./scripts/build.sh",
@@ -15,7 +15,6 @@
1515
"test": "BABEL_ENV=test mocha --opts mocha.opts --reporter dot && npm run lint",
1616
"test:watch": "BABEL_ENV=test mocha --opts mocha.opts --reporter min --watch",
1717
"test:watch:browser": "BABEL_ENV=test karma start",
18-
"watch": "webpack --watch",
1918
"shrinkwrap": "npm-shrinkwrap --dev"
2019
},
2120
"repository": "algolia/instantsearch.js",
@@ -36,6 +35,7 @@
3635
"eslint-plugin-react": "^3.6.3",
3736
"expect": "^1.12.2",
3837
"expect-jsx": "^2.1.0",
38+
"expose-loader": "^0.7.0",
3939
"gh-pages": "^0.4.0",
4040
"jsdoc-parse": "^1.1.1",
4141
"jsdoc-to-markdown": "^1.2.0",

scripts/build.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ license="/*! instantsearch.js ${VERSION:-UNRELEASED} | © Algolia Inc. and other
88

99
bundle='instantsearch'
1010

11-
webpack
11+
# build for jsdelivr, with everything inlined while exposing React + ReactDOM (for plugins)
12+
webpack --config webpack.config.jsdelivr.babel.js
13+
# only transpile to ES5 for package.json main entry
14+
babel index.js -o dist/${bundle}.module.js
1215

1316
for source in "$ROOT"/css/[^_]*.scss; do
1417
base=`basename "$source" .scss`

webpack.config.babel.js webpack.config.jsdelivr.babel.js

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ export default {
1111
module: {
1212
loaders: [{
1313
test: /\.js$/, exclude: /node_modules/, loader: 'babel'
14+
}, {
15+
test: require.resolve('react'), loader: 'expose?React'
16+
}, {
17+
test: require.resolve('react-dom'), loader: 'expose?ReactDOM'
1418
}]
1519
},
1620
plugins: [

0 commit comments

Comments
 (0)