Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@
"no-case": "^2.3.2",
"pug": "^2.0.0-rc.4",
"require-from-string": "^2.0.1",
"slash": "^1.0.0",
"string-hash": "^1.1.3",
"vue": "^2.4.4",
"vue-server-renderer": "^2.4.4",
Expand Down
12 changes: 6 additions & 6 deletions src/utils/require.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// @flow
const Module = require('module');
const path = require('path');
const slash = require('slash');
const Utils = require('./index');
const Renderer = require('../renderer');
const Models = require('../models');
Expand All @@ -14,7 +15,7 @@ class Options {
defaults: Models.Defaults;
constructor(optsObj: Object) {
this.vueFileRegex = /([\w/.\-@_\d]*\.vue)/igm;
this.requireRegex = /(require\(['"])([\w/.\-@_\d]*\.vue)(['"]\))/igm;
this.requireRegex = /(require\(['"])([\w:/.\-@_\d]*\.vue)(['"]\))/igm;
this.appendPaths = optsObj.appendPaths || [];
this.prependPaths = optsObj.prependPaths || [];
this.rootPath = optsObj.rootPath || '';
Expand Down Expand Up @@ -59,25 +60,24 @@ function replaceRelativePaths(code: string, rootPath: string): string {
const currentMatchesDouble = code.match(/(require\("\.\/)/gm);
if (parentMatchesSingle) {
for (const match of parentMatchesSingle) {
code = code.replace(match, `require('${rootPath}/../`);
code = code.replace(match, slash(`require('${rootPath}/../`));
}
}
if (parentMatchesDouble) {
for (const match of parentMatchesDouble) {
code = code.replace(match, `require("${rootPath}/../`);
code = code.replace(match, slash(`require("${rootPath}/../`));
}
}
if (currentMatchesSingle) {
for (const match of currentMatchesSingle) {
code = code.replace(match, `require('${rootPath}/./`);
code = code.replace(match, slash(`require('${rootPath}/./`));
}
}
if (currentMatchesDouble) {
for (const match of currentMatchesDouble) {
code = code.replace(match, `require("${rootPath}/./`);
code = code.replace(match, slash(`require("${rootPath}/./`));
}
}

return code;
}

Expand Down
1 change: 0 additions & 1 deletion tests/example/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ const options = {
}
};


renderer = expressVue.init(options);

const app = express();
Expand Down