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

fix example #245

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 1 addition & 12 deletions example/.babelrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,6 @@
"@babel/preset-react"
],
"plugins": [
"dynamic-import-node",
"@babel/plugin-proposal-class-properties",
"../babel",
[
"module-resolver",
{
"alias": {
"react-loadable": "./src/index.js",
"react-loadable-webpack": "./src/webpack.js"
}
}
]
"../babel"
]
}
4 changes: 2 additions & 2 deletions example/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'path';
import React from 'react';
import ReactDOMServer from 'react-dom/server';
import Loadable from 'react-loadable';
import { getBundles } from 'react-loadable-webpack'
import { getBundles } from 'react-loadable/webpack'
import App from './components/App';

const stats = require('./dist/react-loadable.json');
Expand Down Expand Up @@ -36,10 +36,10 @@ app.get('/', (req, res) => {
</head>
<body>
<div id="app">${html}</div>
<script src="/dist/main.js"></script>
${scripts.map(script => {
return `<script src="/dist/${script.file}"></script>`
}).join('\n')}
<script src="/dist/main.js"></script>
<script>window.main();</script>
</body>
</html>
Expand Down
15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,33 @@
"test": "jest --coverage",
"build": "babel src -d lib",
"start": "yarn build && webpack && babel-node example/server.js",
"prepare": "yarn build"
"prepare": "yarn build && link-module-alias"
},
"dependencies": {
"prop-types": "^15.6.2"
},
"_moduleAliases": {
"react-loadable": "."
},
"devDependencies": {
"@babel/cli": "^7.1.2",
"@babel/core": "^7.1.2",
"@babel/node": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-transform-async-to-generator": "^7.1.0",
"@babel/plugin-transform-object-assign": "^7.0.0",
"@babel/plugin-transform-object-assign": "^7.14.5",
"@babel/preset-env": "^7.1.0",
"@babel/preset-react": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^23.6.0",
"babel-loader": "^8.0.4",
"babel-plugin-dynamic-import-node": "^2.2.0",
"babel-plugin-module-resolver": "^3.1.1",
"express": "^4.16.4",
"flow-bin": "^0.83.0",
"jest": "^23.6.0",
"link-module-alias": "1.x",
"react": "^16.5.2",
"react-dom": "^16.5.2",
"react-test-renderer": "^16.5.2",
"webpack": "^4.20.2"
"webpack": "^4.20.2",
"webpack-cli": "^4.7.2"
},
"peerDependencies": {
"react": "*"
Expand Down
11 changes: 2 additions & 9 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const path = require('path');
const { ReactLoadablePlugin } = require('./webpack');

module.exports = {
mode: "development",
entry: {
main: './example/client',
},
Expand All @@ -25,9 +26,6 @@ module.exports = {
'@babel/preset-react',
],
plugins: [
'syntax-dynamic-import',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-transform-object-assign',
require.resolve('./babel'),
],
}
Expand All @@ -36,14 +34,9 @@ module.exports = {
],
},
devtool: 'inline-source-map',
resolve: {
alias: {
'react-loadable': path.resolve(__dirname, 'src'),
},
},
plugins: [
new ReactLoadablePlugin({
filename: path.resolve(__dirname, 'example', 'dist', 'react-loadable.json'),
filename: 'react-loadable.json',
}),
]
};