Skip to content

Commit

Permalink
Introduce Webpack (#24)
Browse files Browse the repository at this point in the history
This does not represent any functional change to the behavior of the library. Since this component is getting reasonably complex, this diff adds bundling of files via Webpack. I have broken off a first small piece into geometry.js just as an example, and we should continue to split things up further.

Notes:
- Our webpack config emits a umd compatible module. Currently in master we only support es6 style modules.
- See the notes in ./copy-to-example.sh to see how we are using the dist of this lib in the example app
- Some useful resources: https://webpack.js.org/guides/author-libraries/ and https://github.com/kalcifer/webpack-library-example
  • Loading branch information
scottyantipa authored May 22, 2019
1 parent 30ba002 commit 742924a
Show file tree
Hide file tree
Showing 11 changed files with 7,865 additions and 4,947 deletions.
6 changes: 3 additions & 3 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"only": "./index.jsx",
"plugins": ["transform-react-jsx"],
"only": ["src/**"],
"presets": [
["env", {
"@babel/preset-react",
["@babel/preset-env", {
"targets": {
"browsers": ["ie >= 9"]
}
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,6 @@ MapInteraction doesn't require any props. It will control its own internal state
...MapInteractionCSS.propTypes,
}
```

## Development
Please feel free to file issues or put up a PR. There are currently no automated tests, but there is an example application in the `example` directory. When you build this library it will inject the dist into the `example/node_modules` so it can be imported by that application. Annoyingly, create-react-app doesn't watch the `node_modules` directory so you need to manually restart the example app with `npm start`.
9 changes: 9 additions & 0 deletions copy-to-example.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

# This is a hack to work around limitations in create-react-app
# E.g.: https://github.com/facebook/create-react-app/issues/3883
# We completely copy over the dist of this library into the ./example folder's node_modules

mkdir -p example/node_modules/react-map-interaction/dist
cp dist/react-map-interaction.js example/node_modules/react-map-interaction/dist
cp package.json example/node_modules/react-map-interaction/
1 change: 1 addition & 0 deletions example/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SKIP_PREFLIGHT_CHECK=true
5,538 changes: 2,302 additions & 3,236 deletions example/package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example/src/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { Component } from 'react';

// assumes that you have run `npm link react-map-interaction`
// See ../copy-to-example.sh
import { MapInteractionCSS } from 'react-map-interaction';

class App extends Component {
Expand Down
Loading

0 comments on commit 742924a

Please sign in to comment.