简体   繁体   English

导入同构应用

[英]Import in isomorphic app

That doesn't make any sense: 那没有任何意义:

import {Dispatcher} from 'flux';
console.log('Dispatcher', Dispatcher)

I'm using the same boilerplate as usual, the same node version, same compilers, same approaches etc... But the console.log above correctly logs Dispatcher function on server side and undefined on client side. 我正在使用平常相同的样板文件 ,相同的节点版本,相同的编译器,相同的方法等。但是上面的console.log正确地在服务器端记录了Dispatcher函数,而在客户端undefined

If i'm doing this: 如果我正在这样做:

import Flux from 'flux';
console.log('Flux', Flux)

Server side logs: 服务器端日志:
Flux { Dispatcher: [Function: Dispatcher] }

Client side: 客户端:

actions: undefined
constants: {
  TEST_ACTION: "TEST_ACTION" 
}
dispatcher: undefined

Apparently, i'm making just some stupid simple mistake somewhere, but i can't find it. 显然,我在某个地方犯了一些愚蠢的简单错误,但我找不到它。

Dependencies: 依赖关系:

"dependencies": {
    "babel-polyfill": "6.5.0",
    "fetch-plus": "3.8.1",
    "fetch-plus-bearerauth": "3.5.0",
    "fetch-plus-json": "3.6.0",
    "file-loader": "0.8.5",
    "flux": "^2.1.1",
    "isomorphic-fetch": "2.2.1",
    "keymirror": "^0.1.0",
    "koa": "1.2.0",
    "koa-proxy": "0.5.0",
    "koa-static": "2.0.0",
    "object-assign": "^4.0.1",
    "react": "0.14.7",
    "react-dom": "0.14.7",
    "react-inline-css": "2.1.0",
    "react-router": "2.0.0",
    "react-transmit": "3.1.7"
  },
  "devDependencies": {
    "babel": "6.5.2",
    "babel-core": "6.6.5",
    "babel-loader": "6.2.4",
    "babel-preset-es2015": "6.6.0",
    "babel-preset-react": "6.5.0",
    "babel-preset-react-hmre": "1.1.1",
    "babel-preset-stage-0": "6.5.0",
    "concurrently": "2.0.0",
    "forever": "0.15.1",
    "gulp": "^3.9.1",
    "gulp-concat": "^2.6.1",
    "gulp-sass": "^3.0.0",
    "gulp-uglify": "^2.0.0",
    "gulp-uglifycss": "^1.0.6",
    "json-loader": "0.5.4",
    "just-wait": "1.0.5",
    "webpack": "1.13.0",
    "webpack-dev-server": "1.14.1",
    "webpack-node-externals": "1.0.0"
  },

omg... import looks like that: omg ... import看起来像这样:

import {Dispatcher} from 'flux';

this file is located in folder "flux", i've created index.js file within this folder to make it easier to import Actions.js and Dispatcher.js . 该文件位于文件夹“ flux”中,我已经在该文件夹中创建了index.js文件,以使其更易于导入Actions.jsDispatcher.js For some reason webpack assumed that on client side from 'flux' means import from this folder. 出于某种原因,webpack假定在客户端from 'flux'表示从此文件夹导入。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM