Socket
Socket
Sign inDemoInstall

midway-vite-view

Package Overview
Dependencies
228
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.1.0-beta.1 to 2.1.0

36

dist/cli/plugin/cli-plugin-build.js

@@ -90,3 +90,3 @@ "use strict";

shortcut: 'r',
}
},
},

@@ -114,3 +114,3 @@ },

default: path.join(this.rootDir, './view'),
}
},
},

@@ -209,3 +209,4 @@ viteView: {

}
this.options.root = (_f = this.options.root) !== null && _f !== void 0 ? _f : (0, vite_2.normalizePath)(this.midwayConfig.viteView.root);
this.options.root =
(_f = this.options.root) !== null && _f !== void 0 ? _f : (0, vite_2.normalizePath)(this.midwayConfig.viteView.root);
// set absolute path

@@ -231,8 +232,6 @@ Object.keys(this.options).forEach(key => {

for (const [, info] of Object.entries(this.pages)) {
console.log('[vite view] build ' +
((_a = info.viteConfigFile) !== null && _a !== void 0 ? _a : '') +
'\n');
console.log('[vite view] build ' + ((_a = info.viteConfigFile) !== null && _a !== void 0 ? _a : '') + '\n');
await this.buildClient(info.clientIndex, (0, vite_2.normalizePath)(this.options.prefix + `/${info.prefix}/`), path.resolve(this.options.outDir, info.prefix), info.viteConfigFile);
info.entryServers.length &&
await this.buildSSR(info.entryServers, (0, vite_2.normalizePath)(this.options.prefix + `/${info.prefix}/`), this.options.outDir, info.viteConfigFile);
(await this.buildSSR(info.entryServers, (0, vite_2.normalizePath)(this.options.prefix + `/${info.prefix}/`), this.options.outDir, info.viteConfigFile));
}

@@ -264,3 +263,5 @@ }

if (viteConfig.ssr && viteConfig.ssr.format === 'cjs') {
packagePath = lookupFile(viteConfig.root, ['package.json'], { pathOnly: true });
packagePath = lookupFile(viteConfig.root, ['package.json'], {
pathOnly: true,
});
if (packagePath) {

@@ -301,3 +302,3 @@ packageStr = fs.readFileSync(packagePath, 'utf-8');

prefix: this.options.root,
viteConfigFile: this.options.viteConfigFile
viteConfigFile: this.options.viteConfigFile,
};

@@ -312,13 +313,12 @@ }

if (!this.pages[(_a = ssr.viteConfigFile) !== null && _a !== void 0 ? _a : 'default']) {
this.pages[(_b = ssr.viteConfigFile) !== null && _b !== void 0 ? _b : 'default'] =
{
clientIndex: [],
entryServers: [],
viteConfigFile: (_c = ssr.viteConfigFile) !== null && _c !== void 0 ? _c : this.options.viteConfigFile,
prefix: (_d = ssr.root) !== null && _d !== void 0 ? _d : this.options.root,
};
this.pages[(_b = ssr.viteConfigFile) !== null && _b !== void 0 ? _b : 'default'] = {
clientIndex: [],
entryServers: [],
viteConfigFile: (_c = ssr.viteConfigFile) !== null && _c !== void 0 ? _c : this.options.viteConfigFile,
prefix: (_d = ssr.root) !== null && _d !== void 0 ? _d : this.options.root,
};
}
this.pages[((_e = ssr.viteConfigFile) !== null && _e !== void 0 ? _e : 'default')].clientIndex.push(path.resolve(this.options.viewDir, index));
this.pages[(_e = ssr.viteConfigFile) !== null && _e !== void 0 ? _e : 'default'].clientIndex.push(path.resolve(this.options.viewDir, index));
if (ssr.entryServer) {
this.pages[((_f = ssr.viteConfigFile) !== null && _f !== void 0 ? _f : 'default')].entryServers.push(path.resolve(this.options.viewDir, ssr.entryServer));
this.pages[(_f = ssr.viteConfigFile) !== null && _f !== void 0 ? _f : 'default'].entryServers.push(path.resolve(this.options.viewDir, ssr.entryServer));
}

@@ -325,0 +325,0 @@ }

@@ -68,3 +68,5 @@ "use strict";

}
return this.prod ? html : await (await this.vite.createVite(viteConfigFile)).transformIndexHtml(url, html);
return this.prod
? html
: await (await this.vite.createVite(viteConfigFile)).transformIndexHtml(url, html);
}

@@ -71,0 +73,0 @@ async render(name, locals, options) {

@@ -37,5 +37,7 @@ "use strict";

if (!config.base) {
config.base = (0, vite_1.normalizePath)('/' + path.relative(viewRoot, path.resolve(process.cwd(), config.root)) + '/');
config.base = (0, vite_1.normalizePath)('/' +
path.relative(viewRoot, path.resolve(process.cwd(), config.root)) +
'/');
}
}
},
});

@@ -54,3 +56,3 @@ let ViteService = class ViteService {

plugins: [
vitePlugin(this.viewConfig.rootDir.default, this.koaApp.getAppDir())
vitePlugin(this.viewConfig.rootDir.default, this.koaApp.getAppDir()),
],

@@ -71,3 +73,3 @@ server: {

plugins: [
vitePlugin(this.viewConfig.rootDir.default, this.koaApp.getAppDir())
vitePlugin(this.viewConfig.rootDir.default, this.koaApp.getAppDir()),
],

@@ -88,3 +90,3 @@ server: {

getMiddlewareIndex(prefix) {
for (var i = 0; i < this.middlewareArr.length; i++) {
for (let i = 0; i < this.middlewareArr.length; i++) {
if (this.middlewareArr[i].prefix.length <= prefix.length) {

@@ -107,3 +109,3 @@ return i;

middleware: c2k(viteServer.middlewares),
prefix: viteServer.config.base
prefix: viteServer.config.base,
});

@@ -116,3 +118,3 @@ configSet.add(view.viteConfigFile);

middleware: c2k(viteServer.middlewares),
prefix: viteServer.config.base
prefix: viteServer.config.base,
});

@@ -119,0 +121,0 @@ configSet.add(undefined);

@@ -21,7 +21,7 @@ "use strict";

function getPort(port) {
return new Promise((resolve) => {
const server = net.createServer().on('error', (e) => {
return new Promise(resolve => {
const server = net.createServer().on('error', () => {
getPort(++port).then(resolve);
});
server.listen(port, function () {
server.listen(port, () => {
server.close(() => resolve(port));

@@ -28,0 +28,0 @@ });

{
"name": "midway-vite-view",
"version": "2.1.0-beta.1",
"version": "2.1.0",
"description": "midway vite ssr view vue react, midway 的 vite 服务端渲染和客户端渲染组件,支持vue3 react,服务端渲染失败后会自动执行客户端渲染。 Midway's Vite server rendering and client rendering components support vue3 React, Client rendering is automatically performed when server rendering fails。",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -92,3 +92,3 @@ # midway-vite-view

| prod | boolean| 否 |是否是发布环境 如果不传用运行环境是否为prod/production以区分|
| views | `{[key:string]:string|object}` | 是 | key为index.html路径(相对于view文件夹),value为服务端渲染entry-server路径(相对于view文件夹,如果没有entry-server,填'')|
| views | `{[key:string]:string\|object}` | 是 | key为index.html路径(相对于view文件夹),value为服务端渲染entry-server路径(相对于view文件夹,如果没有entry-server,填'')|
| outPrefix | string | 否 | 打包前缀目录,会在static-file文件夹下创建子文件夹进行打包,默认为html |

@@ -95,0 +95,0 @@ | viteConfigFile | string | 否 | vite配置文件地址,默认按vite规则选择vite.config.js/vite.config.ts |

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc