提交 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() { ...@@ -25,16 +25,13 @@ function uniTemplatePlugin() {
name: 'vite:uni-app-template', name: 'vite:uni-app-template',
configResolved() { configResolved() {
const outputDir = process.env.UNI_OUTPUT_DIR; const outputDir = process.env.UNI_OUTPUT_DIR;
return Promise.all([ 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'), {
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,
overwrite: true, });
}), fs_extra_1.default.copySync(path_1.default.resolve(__dirname, '../../lib/template/'), outputDir, {
fs_extra_1.default overwrite: true,
.copy(path_1.default.resolve(__dirname, '../../lib/template/'), outputDir, { });
overwrite: true, fs_extra_1.default.writeFileSync(path_1.default.resolve(outputDir, '__uniappview.html'), genViewHtml());
})
.then(() => fs_extra_1.default.writeFile(path_1.default.resolve(outputDir, '__uniappview.html'), genViewHtml())),
]).then(() => { });
}, },
}; };
} }
......
...@@ -32,25 +32,20 @@ export function uniTemplatePlugin(): Plugin { ...@@ -32,25 +32,20 @@ export function uniTemplatePlugin(): Plugin {
name: 'vite:uni-app-template', name: 'vite:uni-app-template',
configResolved() { configResolved() {
const outputDir = process.env.UNI_OUTPUT_DIR const outputDir = process.env.UNI_OUTPUT_DIR
return Promise.all([ fs.copySync(
fs.copy( require.resolve('@dcloudio/uni-app-plus/dist/uni-app-view.umd.js'),
require.resolve('@dcloudio/uni-app-plus/dist/uni-app-view.umd.js'), path.resolve(outputDir, 'uni-app-view.umd.js'),
path.resolve(outputDir, 'uni-app-view.umd.js'), {
{ overwrite: true,
overwrite: true, }
} )
), fs.copySync(path.resolve(__dirname, '../../lib/template/'), outputDir, {
fs overwrite: true,
.copy(path.resolve(__dirname, '../../lib/template/'), outputDir, { })
overwrite: true, fs.writeFileSync(
}) path.resolve(outputDir, '__uniappview.html'),
.then(() => genViewHtml()
fs.writeFile( )
path.resolve(outputDir, '__uniappview.html'),
genViewHtml()
)
),
]).then(() => {})
}, },
} }
} }
...@@ -12,20 +12,25 @@ export function isRenderjs(id: string) { ...@@ -12,20 +12,25 @@ export function isRenderjs(id: string) {
export function parseRenderjs(id: string) { export function parseRenderjs(id: string) {
if (isWxs(id)) { if (isWxs(id)) {
const { query, filename } = parseVueRequest(id)
return { return {
type: 'wxs', type: 'wxs',
name: (parseVueRequest(id).query as any).name as string, name: (query as any).name as string,
filename,
} as const } as const
} }
if (isRenderjs(id)) { if (isRenderjs(id)) {
const { query, filename } = parseVueRequest(id)
return { return {
type: 'renderjs', type: 'renderjs',
name: (parseVueRequest(id).query as any).name as string, name: (query as any).name as string,
filename,
} as const } as const
} }
return { return {
type: '', type: '',
name: '', name: '',
filename: '',
} as const } as const
} }
......
...@@ -26,7 +26,11 @@ export async function runDev(options: CliOptions & ServerOptions) { ...@@ -26,7 +26,11 @@ export async function runDev(options: CliOptions & ServerOptions) {
}) })
} }
} catch (e) { } 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) process.exit(1)
} }
} }
......
...@@ -31,18 +31,6 @@ export async function buildSSR(options: CliOptions) { ...@@ -31,18 +31,6 @@ export async function buildSSR(options: CliOptions) {
'entry-server.js' 'entry-server.js'
) )
ssrBuildServerOptions.outDir = process.env.UNI_OUTPUT_DIR 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_CLIENT = ''
process.env.UNI_SSR_SERVER = 'true' process.env.UNI_SSR_SERVER = 'true'
await buildByVite( await buildByVite(
......
...@@ -9,6 +9,16 @@ export function createBuild( ...@@ -9,6 +9,16 @@ export function createBuild(
initEasycomsOnce(options.inputDir, options.platform) initEasycomsOnce(options.inputDir, options.platform)
return { return {
rollupOptions: { rollupOptions: {
onwarn(warning, warn) {
if (warning.code === 'UNUSED_EXTERNAL_IMPORT') {
const { message } = warning
// ignore
if (message.includes('"resolveComponent"')) {
return
}
}
warn(warning)
},
output: { output: {
chunkFileNames(chunkInfo) { chunkFileNames(chunkInfo) {
if (chunkInfo.facadeModuleId) { if (chunkInfo.facadeModuleId) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册