vuejs / vue-router

🚦 The official router for Vue 2
http://v3.router.vuejs.org/
MIT License
18.99k stars 5.06k forks source link

assert.js:57 Uncaught AssertionError: path must be a string #695

Closed Steviey closed 8 years ago

Steviey commented 8 years ago

Porting the code from:

vue-router/examples/lazy-loading/app.js

...to another environment (no webpack) throws:

assert.js:57 Uncaught AssertionError: path must be a string.

Environment: "dependencies": { "vue": "^2.0.0-rc.7" }, "devDependencies": { "babel-core": "^6.11.4", "babel-eslint": "^7.0.0", "babel-plugin-transform-runtime": "^6.0.0", "babel-preset-es2015": "^6.9.0", "babel-preset-es2015-loose": "^8.0.0", "babel-preset-flow-vue": "^1.0.0", "babel-preset-stage-2": "^6.0.0", "babel-runtime": "^6.0.0", "babelify": "^7.2.0", "browserify": "^13.1.0", "browserify-hmr": "^0.3.1", "cross-env": "^3.0.0", "envify": "^3.4.1", "http-server": "^0.9.0", "npm-run-all": "^3.1.0", "proxyquireify": "^3.0.1", "uglify-js": "^2.5.0", "vue": "^2.0.0-rc.7", "vue-loader": "^9.5.0", "vue-router": "^2.0.0-rc.5", "vueify": "^9.2.4", "watchify": "^3.4.0" }

fnlctrl commented 8 years ago

Hi, thanks for filling this issue.

  1. The examples were designed to be used with webpack, there's no guarantee they'll work without it.
  2. Browserify doesn't have built-in lazy-loading, so this line in the example would break.
const Foo = resolve => require(['./Foo.vue'], resolve)

You need to configure lazy-loading yourself. (using requirejs etc.)

Steviey commented 8 years ago

Thank you, this is a very important information.

Does this apply to every async feature? http://vuejs.org/guide/components.html#Async-Components

You should point out the webpack-dependency in the description. This would save many hours of investigations.

Unfortunately there are some missleading infos out there too.

https://github.com/vuejs/vue-router/issues/215

The situation is confusing.

fnlctrl commented 8 years ago

Does this apply to every async feature?

Yes.

You should point out the webpack-dependency in the description.

Webpack isn't the only option. There are lots of tools available out there. (requirejs, systemjs, etc.)

Unfortunately there are some missleading infos out there too. #215

In that issue, it was stated that:

No that's the point, using this pattern with webpack is compatible with code splitting (http://webpack.github.io/docs/code-splitting.html) Each require([], resolve) will create a split point and a lazy loaded chunk.

posva commented 8 years ago

Does this apply to every async feature? http://vuejs.org/guide/components.html#Async-Components

@Steviey Actually, it doesn't. Async components in Vue 1 do not depend on the build system but if you want to do lazy loading, you'll always depend on the build system. Beware that async components are deprecated in Vue 2 in favor of async routes

You should read the guide, there's a section about lazy loading