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

I use this to webpack Multiple entry app from create-react-app tips me ReferenceError: webpackJsonp is not defined #250

Closed
xulayen opened this issue Aug 30, 2018 · 3 comments

Comments

@xulayen
Copy link

xulayen commented Aug 30, 2018

I use this to webpack Multiple entry app from create-react-app tips me ReferenceError: webpackJsonp is not defined

Error: Uncaught [ReferenceError: webpackJsonp is not defined]
    at reportException (E:\工\PMP\pmpsummary\node_modules\jsdom\lib\jsdom\living\helpers\runtime-script-errors.js:58:24)
    at processJavaScript (E:\工\PMP\pmpsummary\node_modules\jsdom\lib\jsdom\living\nodes\HTMLScriptElement-impl.js:130:7)
    at HTMLScriptElementImpl._eval (E:\工\PMP\pmpsummary\node_modules\jsdom\lib\jsdom\living\nodes\HTMLScriptElement-impl.js:65:7)
    at E:\工\PMP\pmpsummary\node_modules\jsdom\lib\jsdom\browser\resource-loader.js:31:22
    at Object.check (E:\工\PMP\pmpsummary\node_modules\jsdom\lib\jsdom\living\nodes\Document-impl.js:89:11)
    at E:\工\PMP\pmpsummary\node_modules\jsdom\lib\jsdom\living\nodes\Document-impl.js:108:12
    at wrappedEnqueued (E:\工\PMP\pmpsummary\node_modules\jsdom\lib\jsdom\browser\resource-loader.js:255:16)
    at Request.request [as _callback] (E:\工\PMP\pmpsummary\node_modules\jsdom\lib\jsdom\browser\resource-loader.js:203:9)
    at Request.self.callback (E:\工\PMP\pmpsummary\node_modules\request\request.js:185:22)
    at emitTwo (events.js:126:13) ReferenceError: webpackJsonp is not defined
    at http://localhost:2325/static/js/index.a5b4c900.js:1:1
    at ContextifyScript.Script.runInContext (vm.js:59:29)
    at Object.runInContext (vm.js:120:6)
    at processJavaScript (E:\工\PMP\pmpsummary\node_modules\jsdom\lib\jsdom\living\nodes\HTMLScriptElement-impl.js:128:10)
    at HTMLScriptElementImpl._eval (E:\工\PMP\pmpsummary\node_modules\jsdom\lib\jsdom\living\nodes\HTMLScriptElement-impl.js:65:7)
    at E:\工\PMP\pmpsummary\node_modules\jsdom\lib\jsdom\browser\resource-loader.js:31:22
    at Object.check (E:\工\PMP\pmpsummary\node_modules\jsdom\lib\jsdom\living\nodes\Document-impl.js:89:11)
    at E:\工\PMP\pmpsummary\node_modules\jsdom\lib\jsdom\living\nodes\Document-impl.js:108:12
    at wrappedEnqueued (E:\工\PMP\pmpsummary\node_modules\jsdom\lib\jsdom\browser\resource-loader.js:255:16)
    at Request.request [as _callback] (E:\工\PMP\pmpsummary\node_modules\jsdom\lib\jsdom\browser\resource-loader.js:203:9)
 'render' from react-snapshot was never called. Did you replace the call to ReactDOM.render()?
  plugins: [

    // //2018年8月28日 16:48:56 xulayen添加
    new webpack.optimize.CommonsChunkPlugin({
      name: 'vendor',
      minChunks(module) {
        // any required modules inside node_modules are extracted to vendor
        return (
          module.resource &&
          /\.js$/.test(module.resource) &&
          module.resource.indexOf(
            path.join(__dirname, '../node_modules')
          ) === 0
        )
      }
    }),
]
import { render } from 'react-snapshot';//服务端渲染
import AdminIndex from './admin/index';

render(<AdminIndex />, document.getElementById('root'));
  "scripts": {
    "build": "node scripts/build.js  && react-snapshot",
  },
@stereobooster
Copy link
Owner

stereobooster commented Aug 30, 2018

which version of react-scripts do you use?

@stereobooster
Copy link
Owner

The issue caused by the way webpack inserts chinks in the generated document. react-snap contains workaround for CRA-way configured webpack, other setups may not work as expected. Also discussed here #170

@stereobooster
Copy link
Owner

Also this ticket #145

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants