BoltDoggy / parcel-plugin-vue

⚠️ parcel-bundler/parcel @1.7.0 support Vue Now. This plugin will be not recommended.
https://github.com/parcel-bundler/parcel
209 stars 15 forks source link

Dynamic import - Error: Cannot find module 'xxx' #16

Closed mikkiek closed 6 years ago

mikkiek commented 6 years ago

Hello,

I've got a bit strange issue when i'm trying to create a build and hardly understand what's a reason and how to solve it. The issue appears if i'm using dynamic import, for example: import('./../Application/index.vue').catch(e => alert(e)) I'm revcieving the error

Error: Cannot find module '209'

25eef25dd6d82b322c9283ece5115b27.js:752 Uncaught (in promise) TypeError: Cannot read property '__esModule' of undefined at Ke (25eef25dd6d82b322c9283ece5115b27.js:752) at 25eef25dd6d82b322c9283ece5115b27.js:752 at 25eef25dd6d82b322c9283ece5115b27.js:752 at

There's an interesting thing, If i run parcel index.html --no-cache then everyhing work correct However if i do parcel build index.html --public-url ./ --out-dir www --no-cache the error described above appears. I'll be thankful for any hints. Thank you.

PS. If instead of dynamic import use usual import, then it works in build too.

In my package.json

"dependencies": {
    "babel-polyfill": "^6.26.0",
    "cordova-android": "^7.0.0",
    "cordova-browser": "^5.0.3",
    "cordova-ios": "^4.5.4",
    "cordova-plugin-whitelist": "^1.3.3",
    "onsenui": "^2.8.3",
    "vue": "^2.5.13",
    "vue-onsenui": "^2.4.3",
    "vue-resource": "^1.3.5",
    "vue-router": "^3.0.1",
    "vue-template-compiler": "^2.5.13",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "babel-core": "^6.26.0",
    "babel-preset-env": "^1.6.1",
    "babel-preset-stage-2": "^6.24.1",
    "babel-preset-vue": "^2.0.0",
    "css-loader": "^0.28.8",
    "node-sass": "^4.7.2",
    "parcel-bundler": "^1.3.1",
    "parcel-plugin-vue": "^1.5.0"
  }

in index.html

<!DOCTYPE html>
<html>
<head>
    <meta name="format-detection" content="telephone=no">
    <meta name="msapplication-tap-highlight" content="no">
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
</head>
    <body>
        <div id="application"></div>
        <script type="text/javascript" src="./index.js"></script>
    </body>
</html>

in index.js

"use strict";

// JS
import 'babel-polyfill';
import Vue from 'vue';

// Import Index component
import Index from './components/Index/index.vue';

const application = new Vue({
    render: h => h(Index),
});

application.$mount('#application');

in components/Index/index.vue

<template>
    <div>
        <application></application>
    </div>
</template>

<style>
</style>

<script>
    export default {
        name: 'index',
        components: {
            application: () => import('./../Application/index.vue').catch(e => alert(e))
        }
    }
</script>
in `components/Application/index.vue`
<template>
    <div>
       {{ title }}
    </div>
</template>

<style>
</style>

<script>
    export default {
        data() {
            return ({
                title: 'Hello World! New Order!',
            });
        }
    }
</script>
Software Version(s)
parcel-plugin-vue 1.5.0
Parcel 1.4.1
Vue 2.5.13
Node 9.3.0
npm/Yarn 5.5.1
Operating System Windows 10 / 1703, 15063.850
mikkiek commented 6 years ago

it's fixed in #24 #25