提交 9e9456bb 编写于 作者: fxy060608's avatar fxy060608

build(deps): bump vite from 1.0.0-rc.13 to 2.0.0-beta.4

上级 3001efa9
...@@ -4,14 +4,14 @@ const NodeGlobals = ['module', 'require'] ...@@ -4,14 +4,14 @@ const NodeGlobals = ['module', 'require']
module.exports = { module.exports = {
parser: '@typescript-eslint/parser', parser: '@typescript-eslint/parser',
parserOptions: { parserOptions: {
sourceType: 'module' sourceType: 'module',
}, },
rules: { rules: {
'no-unused-vars': [ 'no-unused-vars': [
'error', 'error',
// we are only using this rule to check for unused arguments since TS // we are only using this rule to check for unused arguments since TS
// catches unused variables but not args. // catches unused variables but not args.
{ varsIgnorePattern: '.*', args: 'after-used', argsIgnorePattern: '^_' } { varsIgnorePattern: '.*', args: 'after-used', argsIgnorePattern: '^_' },
], ],
// most of the codebase are expected to be env agnostic // most of the codebase are expected to be env agnostic
'no-restricted-globals': ['error', ...DOMGlobals, ...NodeGlobals], 'no-restricted-globals': ['error', ...DOMGlobals, ...NodeGlobals],
...@@ -20,8 +20,8 @@ module.exports = { ...@@ -20,8 +20,8 @@ module.exports = {
'no-restricted-syntax': [ 'no-restricted-syntax': [
'error', 'error',
'ObjectExpression > SpreadElement', 'ObjectExpression > SpreadElement',
'ObjectPattern > RestElement' 'ObjectPattern > RestElement',
] ],
}, },
overrides: [ overrides: [
// tests, no restrictions (runs in Node / jest with jsdom) // tests, no restrictions (runs in Node / jest with jsdom)
...@@ -29,28 +29,28 @@ module.exports = { ...@@ -29,28 +29,28 @@ module.exports = {
files: ['**/__tests__/**'], files: ['**/__tests__/**'],
rules: { rules: {
'no-restricted-globals': 'off', 'no-restricted-globals': 'off',
'no-restricted-syntax': 'off' 'no-restricted-syntax': 'off',
} },
}, },
// Packages targeting DOM // Packages targeting DOM
{ {
files: [ files: [
'packages/{uni-components,uni-h5,uni-h5-vue,uni-shared,uni-core}/**' 'packages/{uni-components,uni-h5,uni-h5-vue,uni-shared,uni-core}/**',
], ],
rules: { rules: {
'no-restricted-globals': ['error', ...NodeGlobals] 'no-restricted-globals': ['error', ...NodeGlobals],
} },
}, },
// Packages targeting Node // Packages targeting Node
{ {
files: [ files: [
'packages/{vue-cli-plugin-uni,vue-cli-plugin-hbuilderx}/**', 'packages/{vue-cli-plugin-uni,vue-cli-plugin-hbuilderx,vite-plugin-uni}/**',
'packages/*/vite.config.ts' 'packages/*/vite.config.ts',
], ],
rules: { rules: {
'no-restricted-globals': ['error', ...DOMGlobals], 'no-restricted-globals': ['error', ...DOMGlobals],
'no-restricted-syntax': 'off' 'no-restricted-syntax': 'off',
} },
} },
] ],
} }
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
"packages/*" "packages/*"
], ],
"scripts": { "scripts": {
"dev": "node scripts/dev.js",
"build": "node scripts/build.js", "build": "node scripts/build.js",
"lint": "eslint packages/**/*.ts", "lint": "eslint packages/**/*.ts",
"format": "prettier --write --parser typescript \"packages/**/*.ts?(x)\"", "format": "prettier --write --parser typescript \"packages/**/*.ts?(x)\"",
...@@ -34,41 +33,42 @@ ...@@ -34,41 +33,42 @@
"node": ">=10.0.0" "node": ">=10.0.0"
}, },
"devDependencies": { "devDependencies": {
"@dcloudio/types": "^2.0.0", "@dcloudio/types": "^2.0.20",
"@ls-lint/ls-lint": "^1.8.0", "@ls-lint/ls-lint": "^1.9.2",
"@microsoft/api-extractor": "^7.3.9", "@microsoft/api-extractor": "^7.12.1",
"@rollup/plugin-alias": "^3.1.1", "@rollup/plugin-alias": "^3.1.1",
"@rollup/plugin-commonjs": "^15.0.0", "@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-json": "^4.0.0", "@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^8.0.0", "@rollup/plugin-node-resolve": "^11.0.1",
"@rollup/plugin-replace": "^2.2.1", "@rollup/plugin-replace": "^2.3.4",
"@types/debug": "^4.1.5", "@types/debug": "^4.1.5",
"@types/fs-extra": "^9.0.5", "@types/fs-extra": "^9.0.6",
"@types/jest": "^26.0.0", "@types/jest": "^26.0.19",
"@types/node": "13.11.1", "@types/node": "^14.14.20",
"@types/puppeteer": "^2.0.0", "@types/puppeteer": "^5.4.2",
"@typescript-eslint/parser": "^3.2.0", "@typescript-eslint/parser": "^4.12.0",
"@vue/compiler-sfc": "^3.0.0-rc.9", "@vitejs/plugin-vue": "^1.0.4",
"@vue/compiler-sfc": "^3.0.5",
"brotli": "^1.3.2", "brotli": "^1.3.2",
"eslint": "^7.2.0", "eslint": "^7.17.0",
"fs-extra": "^9.0.1", "fs-extra": "^9.0.1",
"jest": "^26.0.1", "jest": "^26.6.3",
"lint-staged": "^10.2.10", "lint-staged": "^10.5.3",
"mini-types": "^0.1.3", "mini-types": "^0.1.4",
"miniprogram-api-typings": "^2.11.0-1", "miniprogram-api-typings": "^3.2.0",
"prettier": "~1.14.0", "prettier": "^2.2.1",
"puppeteer": "^2.0.0", "puppeteer": "^5.5.0",
"rollup": "^2.16.1", "rollup": "^2.35.1",
"rollup-plugin-node-builtins": "^2.1.2", "rollup-plugin-node-builtins": "^2.1.2",
"rollup-plugin-node-globals": "^1.4.0", "rollup-plugin-node-globals": "^1.4.0",
"rollup-plugin-terser": "^6.1.0", "rollup-plugin-terser": "^7.0.2",
"rollup-plugin-typescript2": "^0.27.1", "rollup-plugin-typescript2": "^0.29.0",
"rollup-plugin-vue": "^6.0.0-beta.10", "rollup-plugin-vue": "^6.0.0",
"semver": "^7.3.2", "semver": "^7.3.4",
"ts-jest": "^26.1.0", "ts-jest": "^26.4.4",
"typescript": "^3.9.3", "typescript": "^4.1.3",
"vite": "^1.0.0-rc.13", "vite": "^2.0.0-beta.4",
"vue": "^3.0.3", "vue": "3.0.5",
"yorkie": "^2.0.0" "yorkie": "^2.0.0"
} }
} }
import fs from 'fs' import { defineConfig } from 'vite'
import path from 'path' import vue from '@vitejs/plugin-vue'
import { isCustomElement } from '../uni-shared' import { isCustomElement } from '../uni-shared'
export default { export default defineConfig({
root: '.', root: '.',
minify: false,
assetsDir: '.',
emitAssets: false,
define: { define: {
__PLATFORM__: JSON.stringify('app-plus') __PLATFORM__: JSON.stringify('app-plus'),
},
plugins: [
vue({
template: {
compilerOptions: {
isCustomElement,
}, },
vueCompilerOptions: {
isCustomElement
}, },
rollupInputOptions: { }),
],
build: {
minify: false,
assetsDir: '.',
rollupOptions: {
input: 'src/index.ts', input: 'src/index.ts',
external: ['vue', '@vue/shared', '@dcloudio/uni-shared'], external: ['vue', '@vue/shared', '@dcloudio/uni-shared'],
preserveEntrySignatures: 'strict' preserveEntrySignatures: 'strict',
}, output: {
rollupOutputOptions: {
format: 'es', format: 'es',
entryFileNames: 'uni-components.esm.js', entryFileNames: 'uni-components.esm.js',
assetFileNames(assetInfo) { assetFileNames(assetInfo) {
...@@ -27,6 +32,9 @@ export default { ...@@ -27,6 +32,9 @@ export default {
return 'uni-components.css' return 'uni-components.css'
} }
return 'assets/[name]-[hash][extname]' return 'assets/[name]-[hash][extname]'
} },
} },
} },
// emitAssets: false,
},
})
import path from 'path' import path from 'path'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import replace from '@rollup/plugin-replace' import replace from '@rollup/plugin-replace'
import { isCustomElement } from '../uni-shared' import { isCustomElement } from '../uni-shared'
...@@ -8,36 +11,53 @@ function resolve(file: string) { ...@@ -8,36 +11,53 @@ function resolve(file: string) {
return path.resolve(__dirname, file) return path.resolve(__dirname, file)
} }
export default { export default defineConfig({
root: '.', root: '.',
minify: false,
assetsDir: '.',
emitAssets: false,
alias: {
'@dcloudio/uni-api': resolve('../uni-api/src/index.ts'),
'@dcloudio/uni-vue': resolve('../uni-vue/src/index.ts'),
'@dcloudio/uni-core': resolve('../uni-core/src/index.ts'),
'@dcloudio/uni-components': resolve('../uni-components/src/index.ts')
},
define: { define: {
global: 'window', global: 'window',
__DEV__: `(process.env.NODE_ENV !== 'production')`, __DEV__: `(process.env.NODE_ENV !== 'production')`,
__PLATFORM__: JSON.stringify('h5') __PLATFORM__: JSON.stringify('h5'),
},
alias: [
{
find: '@dcloudio/uni-api',
replacement: resolve('../uni-api/src/index.ts'),
},
{
find: '@dcloudio/uni-vue',
replacement: resolve('../uni-vue/src/index.ts'),
},
{
find: '@dcloudio/uni-core',
replacement: resolve('../uni-core/src/index.ts'),
},
{
find: '@dcloudio/uni-components',
replacement: resolve('../uni-components/src/index.ts'),
},
],
plugins: [
vue({
template: {
compilerOptions: {
isCustomElement,
}, },
vueCompilerOptions: {
isCustomElement
}, },
rollupInputOptions: { }),
],
build: {
minify: false,
assetsDir: '.',
rollupOptions: {
input: 'src/index.ts', input: 'src/index.ts',
external: ['vue', 'vue-router', '@vue/shared', '@dcloudio/uni-shared'], external: ['vue', 'vue-router', '@vue/shared', '@dcloudio/uni-shared'],
preserveEntrySignatures: 'strict', preserveEntrySignatures: 'strict',
plugins: [ plugins: [
replace({ replace({
createApi: `/*#__PURE__*/ createApi` createApi: `/*#__PURE__*/ createApi`,
}) }),
] ],
}, output: {
rollupOutputOptions: {
format: 'es', format: 'es',
entryFileNames: 'uni-h5.esm.js', entryFileNames: 'uni-h5.esm.js',
assetFileNames(assetInfo) { assetFileNames(assetInfo) {
...@@ -45,6 +65,8 @@ export default { ...@@ -45,6 +65,8 @@ export default {
return 'uni-h5.css' return 'uni-h5.css'
} }
return 'assets/[name]-[hash][extname]' return 'assets/[name]-[hash][extname]'
} },
} },
} },
},
})
...@@ -3247,7 +3247,7 @@ function defineEmit() { ...@@ -3247,7 +3247,7 @@ function defineEmit() {
} }
// Core API ------------------------------------------------------------------ // Core API ------------------------------------------------------------------
const version = "3.0.4"; const version = "3.0.5";
// import deepCopy from './deepCopy' // import deepCopy from './deepCopy'
/** /**
......
...@@ -22,12 +22,13 @@ ...@@ -22,12 +22,13 @@
"license": "Apache-2.0", "license": "Apache-2.0",
"dependencies": { "dependencies": {
"@rollup/pluginutils": "^4.1.0", "@rollup/pluginutils": "^4.1.0",
"debug": "^4.3.1",
"estree-walker": "^2.0.1", "estree-walker": "^2.0.1",
"fs-extra": "^9.0.1", "fs-extra": "^9.0.1",
"magic-string": "^0.25.7" "magic-string": "^0.25.7"
}, },
"peerDependencies": { "peerDependencies": {
"@dcloudio/uni-cli-shared": "^3.0.0", "@dcloudio/uni-cli-shared": "^3.0.0",
"vite": "^1.0.0-rc.13" "vite": "^2.0.0-beta.4"
} }
} }
...@@ -5,7 +5,7 @@ import { vueCompilerOptions } from '@dcloudio/uni-cli-shared' ...@@ -5,7 +5,7 @@ import { vueCompilerOptions } from '@dcloudio/uni-cli-shared'
import { import {
serverPluginEnv, serverPluginEnv,
serverPluginMainJs, serverPluginMainJs,
serverPluginPagesJson serverPluginPagesJson,
} from './server' } from './server'
import { import {
...@@ -13,19 +13,18 @@ import { ...@@ -13,19 +13,18 @@ import {
buildPluginInject, buildPluginInject,
buildPluginMainJs, buildPluginMainJs,
buildPluginPagesJson, buildPluginPagesJson,
buildPluginDynamicImport buildPluginDynamicImport,
} from './build' } from './build'
import { dynamicImportCode } from './utils/dynamicImportUtils' import { initEasycoms, dynamicImportCode, transform } from './utils'
import { initEasycoms } from './utils/easycomUtils'
const VUES = ['vue', 'vue.js', './vue.js'] const VUES = ['vue', 'vue.js', './vue.js', 'dist/vue.runtime.esm-bundler.js']
const plugins = [ const plugins = [
buildPluginMainJs, buildPluginMainJs,
buildPluginPagesJson, buildPluginPagesJson,
buildPluginInject, buildPluginInject,
buildPluginCopy buildPluginCopy,
] ]
if (dynamicImportCode) { if (dynamicImportCode) {
...@@ -33,49 +32,56 @@ if (dynamicImportCode) { ...@@ -33,49 +32,56 @@ if (dynamicImportCode) {
} }
const plugin: Plugin = { const plugin: Plugin = {
define: {
__UNI_WX_API__: true,
__UNI_WXS_API__: true,
__UNI_ROUTER_MODE__: JSON.stringify('hash')
},
resolvers: [
{
alias(id: string) {
if (VUES.includes(id)) {
return '@dcloudio/uni-h5-vue'
}
if (id.startsWith('@/')) {
return id.replace('@/', '/src/')
}
}
}
],
configureServer: [serverPluginEnv, serverPluginMainJs, serverPluginPagesJson], configureServer: [serverPluginEnv, serverPluginMainJs, serverPluginPagesJson],
rollupInputOptions: { rollupInputOptions: {
plugins plugins,
}, },
vueCompilerOptions, vueCompilerOptions,
configureBuild({ root }) { configureBuild({ root }) {
initEasycoms(root) initEasycoms(root)
} },
} }
// TODO 等待 vite 升级支持以下配置 // TODO 等待 vite 升级支持以下配置
Object.assign(plugin, { Object.assign(plugin, {
optimizeDeps: { optimizeDeps: {
exclude: [ exclude: [
'vue',
'vue-router', 'vue-router',
'@dcloudio/uni-h5', '@dcloudio/uni-h5',
'@dcloudio/uni-h5-vue', '@dcloudio/uni-h5-vue',
'@dcloudio/uni-shared' '@dcloudio/uni-shared',
] ],
}, },
chokidarWatchOptions: { chokidarWatchOptions: {
ignored: [ ignored: [
'**/node_modules/**', '**/node_modules/**',
'**/.git/**', '**/.git/**',
'**/uniCloud-aliyun/**', '**/uniCloud-aliyun/**',
'**/uniCloud-tcb/**' '**/uniCloud-tcb/**',
] ],
} },
}) })
export default plugin interface Options {}
export default function uniPlugin(_rawOptions: Options = {}): Plugin {
return {
name: 'vite:uni',
config(config) {
config.define = {
__UNI_WX_API__: true,
__UNI_WXS_API__: true,
__UNI_ROUTER_MODE__: JSON.stringify('hash'),
...config.define,
}
},
async resolveId(id) {
if (VUES.includes(id)) {
return '@dcloudio/uni-h5-vue'
}
if (id.startsWith('@/')) {
return id.replace('@/', '/src/')
}
},
transform,
configureServer() {},
}
}
export * from './serverPluginEnv' export * from './serveEasycom'
export * from './serverPluginMainJs' export * from './serveMainJs'
export * from './serverPluginPagesJson' export * from './servePagesJson'
import { ViteDevServer } from 'vite'
import { initEasycoms } from '../utils'
export const serveEasycom = (server: ViteDevServer) => {
const { dirs, refresh } = initEasycoms(server.config.root)
server.watcher.on('all', (eventName, path) => {
if (!['add', 'unlink'].includes(eventName)) {
return
}
if (dirs.find((dir) => path.startsWith(dir))) {
refresh()
}
})
}
import path from 'path' import path from 'path'
import { ServerPlugin, readBody } from 'vite' import { readBody, ViteDevServer } from 'vite'
import { getRoot, isMainJs, wrapperMainCode } from '../utils' import { getRoot, isMainJs, wrapperMainCode } from '../utils'
export const serverPluginMainJs: ServerPlugin = ({ app, root }) => { export const serveMainJs = (server: ViteDevServer) => {
app.use(async (ctx, next) => { server.app.use(async (ctx, next) => {
await next() await next()
if (isMainJs(ctx.path)) { if (isMainJs(ctx.path)) {
const body = await readBody(ctx.body) const body = await readBody(ctx.body)
......
import { ServerPlugin, readBody } from 'vite' import { ViteDevServer } from 'vite'
import { parsePagesJson } from '../utils' import { parsePagesJson } from '../utils'
...@@ -10,8 +10,8 @@ window.UniViewJSBridge = UniViewJSBridge ...@@ -10,8 +10,8 @@ window.UniViewJSBridge = UniViewJSBridge
window.UniServiceJSBridge = UniServiceJSBridge window.UniServiceJSBridge = UniServiceJSBridge
` `
export const serverPluginPagesJson: ServerPlugin = ({ app }) => { export const servePagesJson = (server: ViteDevServer) => {
app.use(async (ctx, next) => { server.app.use(async (ctx, next) => {
const isPagesJson = ctx.path.endsWith('pages.json') const isPagesJson = ctx.path.endsWith('pages.json')
if (isPagesJson) { if (isPagesJson) {
//skip serverPluginJson //skip serverPluginJson
......
import { ServerPlugin } from 'vite'
import { initEasycoms } from '../utils/easycomUtils'
export const serverPluginEnv: ServerPlugin = ({ root, watcher }) => {
const { dirs, refresh } = initEasycoms(root)
watcher.on('all', (eventName, path) => {
if (!['add', 'unlink'].includes(eventName)) {
return
}
if (dirs.find(dir => path.startsWith(dir))) {
refresh()
}
})
}
...@@ -4,13 +4,13 @@ import { initEasycom } from '@dcloudio/uni-cli-shared' ...@@ -4,13 +4,13 @@ import { initEasycom } from '@dcloudio/uni-cli-shared'
export function initEasycoms(root: string) { export function initEasycoms(root: string) {
const rootDir = path.resolve(root, 'src') const rootDir = path.resolve(root, 'src')
const dirs = ['components'].map(dir => path.resolve(rootDir, dir)) const dirs = ['components'].map((dir) => path.resolve(rootDir, dir))
const easycomOptions = { dirs, rootDir: rootDir } const easycomOptions = { dirs, rootDir: rootDir }
initEasycom(easycomOptions) initEasycom(easycomOptions)
return { return {
dirs, dirs,
refresh() { refresh() {
initEasycom(easycomOptions) initEasycom(easycomOptions)
} },
} }
} }
export * from './mainJsUtils' export * from './mainJs'
export * from './pagesJsonUtils' export * from './easycom'
export * from './dynamicImportUtils' export * from './transform'
export * from './pagesJson'
export * from './dynamicImport'
import path from 'path' import path from 'path'
import slash from 'slash' import slash from 'slash'
import { dynamicImportCode } from './dynamicImportUtils' import { dynamicImportCode } from './dynamicImport'
const MAIN_RE = /main.[jt]s/ const MAIN_RE = /main.[jt]s/
......
...@@ -46,7 +46,7 @@ function formatPages(pagesJson: Record<string, any>, jsonStr: string) { ...@@ -46,7 +46,7 @@ function formatPages(pagesJson: Record<string, any>, jsonStr: string) {
function removePlatformStyle(globalStyle: Record<string, any>) { function removePlatformStyle(globalStyle: Record<string, any>) {
delete globalStyle['app-plus'] delete globalStyle['app-plus']
delete globalStyle['h5'] delete globalStyle['h5']
Object.keys(globalStyle).forEach(name => { Object.keys(globalStyle).forEach((name) => {
if (name.startsWith('mp-') || name.startsWith('quickapp')) { if (name.startsWith('mp-') || name.startsWith('quickapp')) {
delete globalStyle[name] delete globalStyle[name]
} }
...@@ -85,7 +85,7 @@ function formatSubpackages(subpackages: SubpackagesOptions[]) { ...@@ -85,7 +85,7 @@ function formatSubpackages(subpackages: SubpackagesOptions[]) {
function formatPagesJson(jsonStr: string) { function formatPagesJson(jsonStr: string) {
let pagesJson: Record<string, any> = { let pagesJson: Record<string, any> = {
pages: [] pages: [],
} }
//TODO preprocess //TODO preprocess
try { try {
...@@ -116,14 +116,14 @@ function generatePageDefineCode(pageOptions: PageOptions) { ...@@ -116,14 +116,14 @@ function generatePageDefineCode(pageOptions: PageOptions) {
function generatePagesDefineCode(pagesJson: Record<string, any>) { function generatePagesDefineCode(pagesJson: Record<string, any>) {
return (pagesJson.pages as PageOptions[]) return (pagesJson.pages as PageOptions[])
.map(pageOptions => generatePageDefineCode(pageOptions)) .map((pageOptions) => generatePageDefineCode(pageOptions))
.join('\n') .join('\n')
} }
function formatPagesRoute(pagesJson: Record<string, any>): PageRouteOptions[] { function formatPagesRoute(pagesJson: Record<string, any>): PageRouteOptions[] {
const firstPagePath = pagesJson.pages[0].path const firstPagePath = pagesJson.pages[0].path
const tabBarList = (pagesJson.tabBar && pagesJson.tabBar.list) || [] const tabBarList = (pagesJson.tabBar && pagesJson.tabBar.list) || []
return (pagesJson.pages as PageOptions[]).map(pageOptions => { return (pagesJson.pages as PageOptions[]).map((pageOptions) => {
const path = pageOptions.path const path = pageOptions.path
const name = formatPageIdentifier(path) const name = formatPageIdentifier(path)
const isEntry = firstPagePath === path ? true : undefined const isEntry = firstPagePath === path ? true : undefined
...@@ -142,14 +142,14 @@ function formatPagesRoute(pagesJson: Record<string, any>): PageRouteOptions[] { ...@@ -142,14 +142,14 @@ function formatPagesRoute(pagesJson: Record<string, any>): PageRouteOptions[] {
windowTop, windowTop,
topWindow: props.topWindow, topWindow: props.topWindow,
leftWindow: props.leftWindow, leftWindow: props.leftWindow,
rightWindow: props.rightWindow rightWindow: props.rightWindow,
} }
Object.assign(props, meta) Object.assign(props, meta)
return { return {
name, name,
path: pageOptions.path, path: pageOptions.path,
props, props,
meta meta,
} }
}) })
} }
...@@ -169,13 +169,13 @@ function generatePageRoute({ name, path, props, meta }: PageRouteOptions) { ...@@ -169,13 +169,13 @@ function generatePageRoute({ name, path, props, meta }: PageRouteOptions) {
} }
function generatePagesRoute(pagesRouteOptions: PageRouteOptions[]) { function generatePagesRoute(pagesRouteOptions: PageRouteOptions[]) {
return pagesRouteOptions.map(pageOptions => generatePageRoute(pageOptions)) return pagesRouteOptions.map((pageOptions) => generatePageRoute(pageOptions))
} }
function generateRoutes(pagesJson: Record<string, any>) { function generateRoutes(pagesJson: Record<string, any>) {
return [ return [
`{ path: '/${pagesJson.pages[0].path}', redirect: '/' }`, `{ path: '/${pagesJson.pages[0].path}', redirect: '/' }`,
...generatePagesRoute(formatPagesRoute(pagesJson)) ...generatePagesRoute(formatPagesRoute(pagesJson)),
] ]
} }
......
import path from 'path'
import debug from 'debug'
import { TransformHook } from 'rollup'
const debugPre = debug('uni:pre')
const extensions = ['.vue', '.nvue', '.js', '.json', '.css']
export const transform: TransformHook = (code, id) => {
const extname = path.extname(id)
if (!extensions.includes(extname)) {
return
}
// TODO
debugPre(id)
return code
}
...@@ -59,17 +59,21 @@ async function build(target) { ...@@ -59,17 +59,21 @@ async function build(target) {
'vite', 'vite',
['build', '--config', path.resolve(pkgDir, 'vite.config.ts')], ['build', '--config', path.resolve(pkgDir, 'vite.config.ts')],
{ {
stdio: 'inherit' stdio: 'inherit',
} }
) )
} else if (bundler === 'tsc') { } else if (bundler === 'tsc') {
return await execa( const args = [
'tsc', '--listEmittedFiles',
['--listEmittedFiles', types ? `--declaration` : '', '-p', pkgDir], '-p',
{ path.resolve(pkgDir, 'tsconfig.json'),
stdio: 'inherit' ]
if (types) {
args.push('--declaration')
} }
) return await execa('tsc', args, {
stdio: 'inherit',
})
} }
await execa( await execa(
...@@ -79,7 +83,7 @@ async function build(target) { ...@@ -79,7 +83,7 @@ async function build(target) {
'--environment', '--environment',
[`NODE_ENV:${env}`, types ? `TYPES:true` : ``, `TARGET:${target}`] [`NODE_ENV:${env}`, types ? `TYPES:true` : ``, `TARGET:${target}`]
.filter(Boolean) .filter(Boolean)
.join(',') .join(','),
], ],
{ stdio: 'inherit' } { stdio: 'inherit' }
) )
......
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册