Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added module entry point #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
{
"presets": [
[
"env",
{
"loose": true,
"targets": {
"browsers": ["last 2 versions", "ie >= 9"]
}
}
],
"react",
"flow"
],
"plugins": ["transform-class-properties", "add-module-exports"]
"./.babelrc.js"
]
}
27 changes: 27 additions & 0 deletions .babelrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
const { BABEL_ENV, NODE_ENV } = process.env

const modules = BABEL_ENV === 'cjs' || NODE_ENV === 'test' ? 'commonjs' : false

const plugins = ['transform-class-properties']

if (modules === 'commonjs') {
plugins.push('add-module-exports')
}

module.exports = {
presets: [
[
'env',
{
loose: true,
modules,
targets: {
browsers: ['last 2 versions', 'ie >= 9']
}
}
],
'react',
'flow',
],
plugins,
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
node_modules
*.log
lib
es
coverage
.DS_Store
examples/*/bundle.js
Expand Down
28 changes: 23 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,28 @@
"version": "0.1.2",
"description": "Polyfill for the proposed React context API",
"main": "lib/index.js",
"module": "es/index.js",
"repository": "https://github.com/thejameskyle/create-react-context",
"author": "James Kyle <[email protected]>",
"license": "MIT",
"keywords": ["react", "context", "contextTypes", "polyfill", "ponyfill"],
"files": ["lib"],
"keywords": [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reformatting is probably caused by prettier

"react",
"context",
"contextTypes",
"polyfill",
"ponyfill"
],
"files": [
"lib",
"es"
],
"scripts": {
"test": "jest",
"flow": "flow",
"format": "prettier --write '**/*.{js,md,json,js.flow,d.ts}'",
"build": "babel src -d lib --copy-files --ignore __tests__",
"build": "npm run build:es && npm run build:cjs",
"build:es": "cross-env BABEL_ENV=es babel src -d es --copy-files --ignore __tests__",
"build:cjs": "cross-env BABEL_ENV=cjs babel src -d lib --copy-files --ignore __tests__",
"prepublish": "yarn build",
"commit": "lint-staged"
},
Expand All @@ -27,6 +39,7 @@
"babel-preset-env": "^1.6.1",
"babel-preset-flow": "^6.23.0",
"babel-preset-react": "^6.24.1",
"cross-env": "^5.1.1",
"enzyme": "^3.2.0",
"enzyme-adapter-react-16": "^1.1.0",
"enzyme-to-json": "^3.2.2",
Expand All @@ -41,10 +54,15 @@
"react-dom": "^16.2.0"
},
"lint-staged": {
"*.{js,md,json,js.flow,d.ts}": ["prettier --write", "git add"]
"*.{js,md,json,js.flow,d.ts}": [
"prettier --write",
"git add"
]
},
"jest": {
"snapshotSerializers": ["enzyme-to-json/serializer"]
"snapshotSerializers": [
"enzyme-to-json/serializer"
]
},
"dependencies": {
"mitt": "^1.1.3"
Expand Down
13 changes: 12 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1047,7 +1047,14 @@ cosmiconfig@^3.1.0:
parse-json "^3.0.0"
require-from-string "^2.0.1"

cross-spawn@^5.0.1:
cross-env@^5.1.1:
version "5.1.1"
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.1.1.tgz#b6d8ab97f304c0f71dae7277b75fe424c08dfa74"
dependencies:
cross-spawn "^5.1.0"
is-windows "^1.0.0"

cross-spawn@^5.0.1, cross-spawn@^5.1.0:
version "5.1.0"
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"
dependencies:
Expand Down Expand Up @@ -1956,6 +1963,10 @@ is-utf8@^0.2.0:
version "0.2.1"
resolved "https://registry.yarnpkg.com/is-utf8/-/is-utf8-0.2.1.tgz#4b0da1442104d1b336340e80797e865cf39f7d72"

is-windows@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.1.tgz#310db70f742d259a16a369202b51af84233310d9"

[email protected], isarray@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11"
Expand Down