Open ibio opened 7 years ago
Can confirm. Having the same problem when upgrading to webpack 2.2.1
Webpack 1 used the browserify
main field in package.json. That behavior was removed in Webpack 2. If you want to keep that behavior, add it back to your webpack config in resolve.mainFields. Otherwise, add a resolve.alias for director
.
import { Router } from 'director/build/director';
...
...
...
const router = new Router().init();
this worked for me on Webpack2
This works. But when I try to server render I get a document is not defined
error. Seems like this didn't happen when importing the other way.
Same Issue for me. When using
import { Router } from 'director';
Getting error init is not a function
if use
import { Router } from 'director/build/director';
Server side rendering is not working. Getting error document is not defined
@javidan did you test my suggestion?
@javidan do you know the reason importing from 'director/build/director' works?
@ClearedFram3 see my comment above. Webpack 1 used to read the browserify
package.json setting that specified director/build/director
. Webpack 2 dropped that behavior.
Correct import introduction
import {Router} from 'director/build/director.js'
When I upgraded to webpack2/npm(4.1.2), it raised the following runtime error:
Uncaught TypeError: this.configure is not a function at Object.exports.Router (webpack:///./~/director/lib/director/router.js?:181) at init (webpack:///./app/view/router.jsx?:58) at eval (webpack:///./app/view/router.jsx?:121) at Object.212 (app.js:2) at n (vendor.js:1) at eval (webpack:///./app/main.js?:5) at Object.529 (app.js:9) at n (vendor.js:1) at window.webpackJsonp (vendor.js:1) at app.js:1
I figured it out that webpack2 somehow did not recognize the ./build path, instead it used ./lib path, which is declared in package.json("main": "./lib/director"). I believe there are some issues because what's in the ./lib is not complete code and we can only use the code in ./build path.
However, I am wondering why it worked fined with webpack1. Plese let me know what happened here. thanks :)