refactor(@vant/cli): migrate to ESM package

This commit is contained in:
chenjiahan
2021-10-28 11:48:11 +08:00
committed by neverland
parent eec2ac4c0f
commit 1b45f38133
50 changed files with 255 additions and 196 deletions

View File

@@ -0,0 +1,26 @@
/**
* @babel/preset-typescript 不支持编译 Vue 文件中的 ts 代码
* 通过手动添加 @babel/plugin-transform-typescript 的方式来解决这个问题
* see: https://github.com/babel/babel-loader/pull/738
*/
const { readFileSync } = require('fs');
const { declare } = require('@babel/helper-plugin-utils');
module.exports = declare(() => ({
overrides: [
{
test: (filePath) => {
if (/\.vue$/.test(filePath)) {
const template = readFileSync(filePath, { encoding: 'utf8' });
return (
template.includes('lang="ts"') || template.includes("lang='ts'")
);
}
return false;
},
plugins: [require('@babel/plugin-transform-typescript')],
},
],
}));