提交 3e8cf51e 编写于 作者: fxy060608's avatar fxy060608

chore: remove resolveComponent warning

上级 24dfc6f6
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.uniRenderjsPlugin = void 0;
const debug_1 = __importDefault(require("debug"));
const uni_cli_shared_1 = require("@dcloudio/uni-cli-shared");
const debugRenderjs = debug_1.default('vite:uni:renderjs');
function uniRenderjsPlugin() {
return {
name: 'vite:uni-app-renderjs',
transform(code, id) {
const { type, name } = uni_cli_shared_1.parseRenderjs(id);
if (!type) {
return;
}
debugRenderjs(id);
if (!name) {
this.error(uni_cli_shared_1.missingModuleName(type, code));
}
this.emitFile({
fileName: '.renderjs.js',
type: 'asset',
source: code,
});
return '';
},
};
}
exports.uniRenderjsPlugin = uniRenderjsPlugin;
......@@ -25,16 +25,13 @@ function uniTemplatePlugin() {
name: 'vite:uni-app-template',
configResolved() {
const outputDir = process.env.UNI_OUTPUT_DIR;
return Promise.all([
fs_extra_1.default.copy(require.resolve('@dcloudio/uni-app-plus/dist/uni-app-view.umd.js'), path_1.default.resolve(outputDir, 'uni-app-view.umd.js'), {
overwrite: true,
}),
fs_extra_1.default
.copy(path_1.default.resolve(__dirname, '../../lib/template/'), outputDir, {
overwrite: true,
})
.then(() => fs_extra_1.default.writeFile(path_1.default.resolve(outputDir, '__uniappview.html'), genViewHtml())),
]).then(() => { });
fs_extra_1.default.copySync(require.resolve('@dcloudio/uni-app-plus/dist/uni-app-view.umd.js'), path_1.default.resolve(outputDir, 'uni-app-view.umd.js'), {
overwrite: true,
});
fs_extra_1.default.copySync(path_1.default.resolve(__dirname, '../../lib/template/'), outputDir, {
overwrite: true,
});
fs_extra_1.default.writeFileSync(path_1.default.resolve(outputDir, '__uniappview.html'), genViewHtml());
},
};
}
......
......@@ -32,25 +32,20 @@ export function uniTemplatePlugin(): Plugin {
name: 'vite:uni-app-template',
configResolved() {
const outputDir = process.env.UNI_OUTPUT_DIR
return Promise.all([
fs.copy(
require.resolve('@dcloudio/uni-app-plus/dist/uni-app-view.umd.js'),
path.resolve(outputDir, 'uni-app-view.umd.js'),
{
overwrite: true,
}
),
fs
.copy(path.resolve(__dirname, '../../lib/template/'), outputDir, {
overwrite: true,
})
.then(() =>
fs.writeFile(
path.resolve(outputDir, '__uniappview.html'),
genViewHtml()
)
),
]).then(() => {})
fs.copySync(
require.resolve('@dcloudio/uni-app-plus/dist/uni-app-view.umd.js'),
path.resolve(outputDir, 'uni-app-view.umd.js'),
{
overwrite: true,
}
)
fs.copySync(path.resolve(__dirname, '../../lib/template/'), outputDir, {
overwrite: true,
})
fs.writeFileSync(
path.resolve(outputDir, '__uniappview.html'),
genViewHtml()
)
},
}
}
......@@ -12,20 +12,25 @@ export function isRenderjs(id: string) {
export function parseRenderjs(id: string) {
if (isWxs(id)) {
const { query, filename } = parseVueRequest(id)
return {
type: 'wxs',
name: (parseVueRequest(id).query as any).name as string,
name: (query as any).name as string,
filename,
} as const
}
if (isRenderjs(id)) {
const { query, filename } = parseVueRequest(id)
return {
type: 'renderjs',
name: (parseVueRequest(id).query as any).name as string,
name: (query as any).name as string,
filename,
} as const
}
return {
type: '',
name: '',
filename: '',
} as const
}
......
......@@ -26,7 +26,11 @@ export async function runDev(options: CliOptions & ServerOptions) {
})
}
} catch (e) {
console.error(`error when starting dev server:\n${e.stack || e}`)
if (options.platform === 'h5') {
console.error(`error when starting dev server:\n${e.stack || e}`)
} else {
console.error(`error during build:\n${e.stack || e}`)
}
process.exit(1)
}
}
......
......@@ -31,18 +31,6 @@ export async function buildSSR(options: CliOptions) {
'entry-server.js'
)
ssrBuildServerOptions.outDir = process.env.UNI_OUTPUT_DIR
ssrBuildServerOptions.rollupOptions = {
onwarn(warning, warn) {
if (warning.code === 'UNUSED_EXTERNAL_IMPORT') {
const { message } = warning
// ignore
if (message.includes('"resolveComponent"')) {
return
}
}
warn(warning)
},
}
process.env.UNI_SSR_CLIENT = ''
process.env.UNI_SSR_SERVER = 'true'
await buildByVite(
......
......@@ -9,6 +9,16 @@ export function createBuild(
initEasycomsOnce(options.inputDir, options.platform)
return {
rollupOptions: {
onwarn(warning, warn) {
if (warning.code === 'UNUSED_EXTERNAL_IMPORT') {
const { message } = warning
// ignore
if (message.includes('"resolveComponent"')) {
return
}
}
warn(warning)
},
output: {
chunkFileNames(chunkInfo) {
if (chunkInfo.facadeModuleId) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册