Skip to content

Commit 80a0ee2

Browse files
tests are half done
1 parent a3f189e commit 80a0ee2

15 files changed

+1870
-936
lines changed

.babelrc

-9
This file was deleted.

.vscode/launch.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@
44
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
55
"version": "0.2.0",
66
"configurations": [
7+
78
{
89
"type": "node",
910
"request": "attach",
1011
"name": "Attach",
1112
"restart": true,
1213
"protocol": "inspector",
13-
"port": 9230
14+
"port": 9229
1415
}
1516
]
1617
}

lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-check
22

3-
const RendererVueify = require("./renderer/renderer");
3+
const RendererVueify = require("./renderer/renderer-vueify");
44
const RendererWebpack = require("./renderer/renderer-webpack");
55

66
module.exports.ProntoVueify = RendererVueify;

lib/renderer/renderer.js lib/renderer/renderer-vueify.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ const jsToString = require("js-to-string");
4343
* @prop {String} vueVersion
4444
* @prop {(VueOptionsType|Object)} head
4545
* @prop {Object} data
46+
* @prop {Object} babel
4647
*/
4748

4849
class Renderer {
@@ -54,6 +55,7 @@ class Renderer {
5455
* @property {String} rootPath
5556
* @property {String} nodeModulesPath
5657
* @property {String} vueVersion
58+
* @property {Object} babel
5759
*/
5860
constructor(options = {}) {
5961

@@ -62,7 +64,7 @@ class Renderer {
6264
maxAge: 1000 * 60 * 60,
6365
};
6466
this.renderer = vueServerRenderer.createRenderer();
65-
this.lruCache = LRU(this.cacheOptions);
67+
this.lruCache = new LRU(this.cacheOptions);
6668
this.internalCache = new Utils.Cache();
6769
this.head = options.head || {};
6870
this.data = options.data || {};
@@ -77,7 +79,10 @@ class Renderer {
7779
}
7880
}
7981
this.rootPath = Utils.FindRootPath(options.rootPath);
80-
82+
this.babel = options.babel;
83+
if (options.babel) {
84+
vueify.compiler.applyConfig({ babel: options.babel});
85+
}
8186
if (!process.env.VUE_DEV) {
8287
// find all the vue files and try to precompile them and store them in cache
8388
find.file(/\.vue$/, this.rootPath,
@@ -346,7 +351,10 @@ class Renderer {
346351
};
347352

348353
const stylesArray = vueCompiler.parseComponent(content, { pad: true }).styles;
349-
// @ts-ignore
354+
355+
if (vm.babel) {
356+
vueify.compiler.applyConfig({ babel: vm.babel});
357+
}
350358
const compiler = vueify.compiler;
351359
compiler.compile(content, filePath,
352360
/**

lib/renderer/renderer-webpack.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class Renderer {
153153
],
154154
};
155155

156-
if (!process.env.VUE_DEV) {
156+
if (process.env.VUE_DEV) {
157157
// find all the vue files and try to precompile them and store them in cache
158158
find.file(
159159
/\.vue$/,
@@ -171,7 +171,7 @@ class Renderer {
171171
})
172172
.catch(error => {
173173
console.error(
174-
`Error Precaching \nfilePath -> ${filePath}\n-------\n${error}`,
174+
`Error Precaching \nfilePath -> ${filePath}\n-------\n${error}\n\n`,
175175
);
176176
});
177177
}
@@ -272,9 +272,10 @@ class Renderer {
272272
clientBundlePath: clientBundleFile,
273273
});
274274
} catch (error) {
275-
275+
//file was not found so make it
276276
const compiler = webpack(config.config);
277277
compiler.outputFileSystem = this.mfs;
278+
const vm = this;
278279
compiler.run((err, stats) => {
279280
if (err) {
280281
reject(err);
@@ -286,8 +287,8 @@ class Renderer {
286287
}
287288
});
288289
try {
289-
const serverBundle = this.mfs.readFileSync(serverBundleFile, "utf-8");
290-
const clientBundle = this.mfs.readFileSync(serverBundleFile, "utf-8");
290+
const serverBundle = vm.mfs.readFileSync(serverBundleFile, "utf-8");
291+
const clientBundle = vm.mfs.readFileSync(clientBundleFile, "utf-8");
291292
if (!serverBundle || !clientBundle) {
292293
reject(new Error("Couldn't load bundle"));
293294
}

lib/utils/layout-webpack.js

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ function BuildLayout(layoutObject) {
1111
end: "",
1212
};
1313

14-
1514
if (layoutObject) {
1615
const layout = new Layout(layoutObject.template);
1716
finishedLayout.start = `${layout.html.start}<head>${layoutObject.head}</head>${layout.body.start}${layout.template.start}`;

0 commit comments

Comments
 (0)