Skip to content

Commit

Permalink
examples/hello-world works
Browse files Browse the repository at this point in the history
  • Loading branch information
xcatliu committed Dec 29, 2015
1 parent 80020e0 commit 210947b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 53 deletions.
2 changes: 1 addition & 1 deletion .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"presets": ["es2015", "stage-0"],
"plugins": [
"add-module-exports",
"transform-object-assign"
]
}
38 changes: 0 additions & 38 deletions examples/buildAll.js

This file was deleted.

22 changes: 18 additions & 4 deletions examples/hello-world/entry.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
import reactIE8 from 'react-ie8';
reactIE8();
/**
* CANNOT use `import` to import `react-ie8`,
* because `import` will be transformed to `Object.defineProperty`,
* which doesn't exists in IE8 (but will be polyfilled after `require('react-ie8')()` executed).
*/
// import reactIE8 from 'react-ie8';
// reactIE8();

import React from 'react';
import ReactDOM from 'react-dom';
require('react-ie8')();

/**
* CANNOT use `import` to import `react` or `react-dom`,
* because `import` will run `react` before `require('react-ie8')()`.
*/
// import React from 'react';
// import ReactDOM from 'react-dom';

const React = require('react');
const ReactDOM = require('react-dom');

ReactDOM.render(
<h1>Hello World</h1>,
Expand Down
6 changes: 4 additions & 2 deletions examples/hello-world/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"description": "React IE8 Hello World Example",
"main": "entry.js",
"scripts": {
"build": "webpack entry.js bundle.js",
"start": "npm run build && npm run serve",
"build": "npm i ../.. && webpack entry.js bundle.js",
"serve": "ecstatic --cache=false",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
Expand All @@ -27,7 +29,7 @@
"babel-preset-es2015": "^6.3.13",
"babel-preset-react": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"es3ify-loader": "^0.1.0",
"ecstatic": "^1.4.0",
"webpack": "^1.12.9"
}
}
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@
"build:lib": "babel src --out-dir lib",
"build": "npm run build:lib",
"prepublish": "npm run clean && npm run build",
"examples:build": "babel-node examples/buildAll.js",
"examples:serve-static": "ecstatic --cache=false examples",
"examples": "npm run examples:build && npm run examples:serve-static",
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
Expand All @@ -30,11 +27,15 @@
"homepage": "https://github.com/xcatliu/react-ie8",
"dependencies": {
"console-polyfill": "^0.2.2",
"core-js": "^2.0.0",
"es5-shim": "^4.4.1"
},
"devDependencies": {
"babel": "^6.3.26",
"babel-cli": "^6.3.17",
"babel-core": "^6.3.26",
"babel-eslint": "^5.0.0-beta6",
"babel-plugin-add-module-exports": "^0.1.2",
"babel-plugin-transform-object-assign": "^6.3.13",
"babel-preset-es2015": "^6.3.13",
"babel-preset-stage-0": "^6.3.13",
"babelify": "^6.1.2",
Expand Down
6 changes: 2 additions & 4 deletions src/react-ie8.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,9 @@ const defaultOptions = {
// 'font-face': false,
};

export default function reactIE8(options = {}) {
module.exports = function reactIE8(options = {}) {
const finalOptions = Object.assign({}, defaultOptions, options);
if (finalOptions['es5-shim']) require('es5-shim');
if (finalOptions['es5-sham']) require('es5-shim/es5-sham');
if (finalOptions['console-polyfill']) require('console-polyfill');
// if (finalOptions['html5shiv']) require('html5shiv');
// Object.keys(finalOptions).filter((key) => finalOptions[key]).
}
};

0 comments on commit 210947b

Please sign in to comment.