mirror of
https://github.com/youzan/vant.git
synced 2025-10-16 08:00:34 +00:00
Merge branch 'dev' into next
This commit is contained in:
@@ -1,5 +1,11 @@
|
||||
# 更新日志
|
||||
|
||||
## v4.0.2
|
||||
|
||||
`2022-05-14`
|
||||
|
||||
- 修复编译 script setup 错误的问题
|
||||
|
||||
## v4.0.1
|
||||
|
||||
`2022-03-03`
|
||||
|
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@vant/cli",
|
||||
"version": "4.0.1",
|
||||
"version": "4.0.2",
|
||||
"type": "module",
|
||||
"main": "lib/index.js",
|
||||
"typings": "lib/index.d.ts",
|
||||
@@ -70,7 +70,7 @@
|
||||
"gh-pages": "^3.2.3",
|
||||
"hash-sum": "^2.0.0",
|
||||
"highlight.js": "^11.3.1",
|
||||
"husky": "^7.0.4",
|
||||
"husky": "^8.0.1",
|
||||
"jest": "^27.3.1",
|
||||
"jest-canvas-mock": "^2.3.1",
|
||||
"jest-serializer-html": "^7.1.0",
|
||||
|
@@ -2,7 +2,7 @@ import fse from 'fs-extra';
|
||||
import babel from '@babel/core';
|
||||
import esbuild, { type Format } from 'esbuild';
|
||||
import { sep } from 'path';
|
||||
import { isJsx, replaceExt } from '../common/index.js';
|
||||
import { isJsx, replaceExt, getVantConfig } from '../common/index.js';
|
||||
import { replaceCSSImportExt } from '../common/css.js';
|
||||
import { replaceScriptImportExt } from './get-deps.js';
|
||||
|
||||
@@ -50,7 +50,9 @@ export async function compileScript(
|
||||
|
||||
({ code } = esbuildResult);
|
||||
|
||||
const jsFilePath = replaceExt(filePath, '.js');
|
||||
const extensionMap = getVantConfig().build?.extensions;
|
||||
const extension = extensionMap?.[format] || '.js';
|
||||
const jsFilePath = replaceExt(filePath, extension);
|
||||
removeSync(filePath);
|
||||
outputFileSync(jsFilePath, code);
|
||||
}
|
||||
|
@@ -1,7 +1,12 @@
|
||||
import fse from 'fs-extra';
|
||||
import path from 'path';
|
||||
import hash from 'hash-sum';
|
||||
import { parse, SFCBlock, compileTemplate } from 'vue/compiler-sfc';
|
||||
import {
|
||||
parse,
|
||||
SFCBlock,
|
||||
compileTemplate,
|
||||
compileScript,
|
||||
} from 'vue/compiler-sfc';
|
||||
import { replaceExt } from '../common/index.js';
|
||||
|
||||
const { remove, readFileSync, outputFile } = fse;
|
||||
@@ -73,8 +78,9 @@ export async function compileSfc(filePath: string): Promise<any> {
|
||||
const scopeId = hasScoped ? `data-v-${hash(source)}` : '';
|
||||
|
||||
// compile js part
|
||||
if (descriptor.script) {
|
||||
const lang = descriptor.script.lang || 'js';
|
||||
if (descriptor.script || descriptor.scriptSetup) {
|
||||
const lang =
|
||||
descriptor.script?.lang || descriptor.scriptSetup?.lang || 'js';
|
||||
const scriptFilePath = replaceExt(filePath, `.${lang}`);
|
||||
|
||||
tasks.push(
|
||||
@@ -86,7 +92,14 @@ export async function compileSfc(filePath: string): Promise<any> {
|
||||
script += '// @ts-nocheck\n';
|
||||
}
|
||||
|
||||
script += descriptor.script!.content;
|
||||
if (descriptor.scriptSetup) {
|
||||
script += compileScript(descriptor, {
|
||||
id: scopeId,
|
||||
}).content;
|
||||
} else {
|
||||
script += descriptor.script!.content;
|
||||
}
|
||||
|
||||
script = injectStyle(script, styles, filePath);
|
||||
script = script.replace(EXPORT, `const ${VUEIDS} =`);
|
||||
|
||||
|
@@ -14,7 +14,9 @@ export function getViteConfigForPackage({
|
||||
}): InlineConfig {
|
||||
setBuildTarget('package');
|
||||
|
||||
const { name } = getVantConfig();
|
||||
const { name, build } = getVantConfig();
|
||||
const entryExtension = build?.extensions?.esm || '.js';
|
||||
const entry = join(ES_DIR, `index${entryExtension}`);
|
||||
|
||||
return {
|
||||
root: CWD,
|
||||
@@ -24,7 +26,7 @@ export function getViteConfigForPackage({
|
||||
build: {
|
||||
lib: {
|
||||
name,
|
||||
entry: join(ES_DIR, 'index.js'),
|
||||
entry,
|
||||
formats,
|
||||
fileName: (format: string) => {
|
||||
const suffix = format === 'umd' ? '' : `.${format}`;
|
||||
|
Reference in New Issue
Block a user