Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nested single file component parsing error when containing js regex? #110

Open
eisfair opened this issue Nov 25, 2017 · 0 comments
Open

Comments

@eisfair
Copy link

eisfair commented Nov 25, 2017

I experience some strange behavior when there is a nested component with some regex.

The Problem: express server sends no response, but also throws no error.

You may try to reproduce this with an easy setup together with express-vue:

The route:

router.get('/', function(req, res) {
    res.renderVue('index', {});
});
#index.vue
<template>
    <div></div>
</template>

<script>
    import NestedComponent from 'nestedComponent.vue';
</script>

<style>
</style>
#nestedComponent.vue
<template>
    <div></div>
</template>

<style>
</style>

<script>
    export default {
        mounted: function() {
            let search = "".replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
        }
    }
</script>

I could track down the problem to the following:
in lib/index.js the following code gets called and waits for the promise to resolve.

//lib/index.js
Utils.setupComponent(path.join(Options.rootPath, componentPath), Options, _this.Cache)

In lib/utils/component.js the resolve in line 14 gets called but somehow never really makes it back to lib/index.js where it should proceed with .then

//lib/utils/component.js
'use strict';

var Models = require('../models');
var Parser = require('../parser');
var PathUtils = require('./checkPathUtils');

var types = new Models.Types();

function setupComponent(componentPath, defaults, Cache) {
    return new Promise(function (resolve, reject) {
        var vueFile = componentPath.includes('.vue') ? componentPath : componentPath + '.vue';
        PathUtils.getCorrectPathForFile(vueFile, 'view', defaults, Cache).then(function (path) {
            Parser.componentParser(path.path, defaults, types.COMPONENT, Cache).then(function (component) {
 -->               resolve(component);
            }).catch(function (error) {
                reject(error);
            });
        }).catch(function (error) {
            reject(error);
        });
    });
}

module.exports = setupComponent;

That's the last point where i can keep track of the debugging session.

Best regards,
Christian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant