繁体   English   中英

导入同构应用

[英]Import in isomorphic app

那没有任何意义:

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

我正在使用平常相同的样板文件 ,相同的节点版本,相同的编译器,相同的方法等。但是上面的console.log正确地在服务器端记录了Dispatcher函数,而在客户端undefined

如果我正在这样做:

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

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

客户端:

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

显然,我在某个地方犯了一些愚蠢的简单错误,但我找不到它。

依赖关系:

"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看起来像这样:

import {Dispatcher} from 'flux';

该文件位于文件夹“ flux”中,我已经在该文件夹中创建了index.js文件,以使其更易于导入Actions.jsDispatcher.js 出于某种原因,webpack假定在客户端from 'flux'表示从此文件夹导入。

暂无
暂无

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

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