From 1dc57633847dd68a03fd05e79bc031dabf3b9085 Mon Sep 17 00:00:00 2001 From: Rahul Kadyan Date: Wed, 27 Apr 2022 03:28:20 -0700 Subject: [PATCH] fix bundle --- .../vscode-vue-language-features/package.json | 2 +- extensions/vscode-vue/package.json | 2 +- .../src/rollup-plugin-esbuild.ts | 6 ++++++ packages/monorepo-tools/src/rollup.ts | 12 +++++++---- .../src/project/FilesystemHost.ts | 2 +- .../projectconfig/src/project/VueProject.ts | 4 ++-- packages/transforms/src/index.ts | 20 ++++++++++++------- .../src/BlockTransformer.ts | 3 +++ 8 files changed, 35 insertions(+), 16 deletions(-) diff --git a/extensions/vscode-vue-language-features/package.json b/extensions/vscode-vue-language-features/package.json index ba54502d..17731fe8 100644 --- a/extensions/vscode-vue-language-features/package.json +++ b/extensions/vscode-vue-language-features/package.json @@ -4,7 +4,7 @@ "name": "vue-language-features", "publisher": "znck", "displayName": "VueDX", - "version": "0.10.3", + "version": "0.10.4", "description": "Advanced TypeScript/JavaScript support for Vue", "icon": "logo.png", "main": "dist/index.js", diff --git a/extensions/vscode-vue/package.json b/extensions/vscode-vue/package.json index 9588c4f8..5cd145b4 100644 --- a/extensions/vscode-vue/package.json +++ b/extensions/vscode-vue/package.json @@ -4,7 +4,7 @@ "name": "vue", "publisher": "znck", "displayName": "Vue", - "version": "0.10.3", + "version": "0.10.4", "description": "Syntax Highlight", "icon": "logo.png", "main": "dist/index.js", diff --git a/packages/monorepo-tools/src/rollup-plugin-esbuild.ts b/packages/monorepo-tools/src/rollup-plugin-esbuild.ts index 89d5b59b..c75af153 100644 --- a/packages/monorepo-tools/src/rollup-plugin-esbuild.ts +++ b/packages/monorepo-tools/src/rollup-plugin-esbuild.ts @@ -23,6 +23,7 @@ import type { export function esbuild( config: boolean | BuildOptions, getExternal: () => ExternalOption | undefined, + minify: boolean = process.env['CI'] != null, ): Plugin { let format: 'iife' | 'cjs' | 'esm' = 'esm' let outputOptions!: OutputOptions @@ -170,6 +171,11 @@ export function esbuild( outfile: fileName, treeShaking: true, resolveExtensions: ['.mjs', '.js', '.cjs'], + minify: minify, + minifyIdentifiers: minify, + minifyWhitespace: minify, + minifySyntax: minify, + legalComments: 'none', ...defaults, sourcemap: 'external', entryPoints: [fileName], diff --git a/packages/monorepo-tools/src/rollup.ts b/packages/monorepo-tools/src/rollup.ts index 5a279c96..cd1f57a9 100644 --- a/packages/monorepo-tools/src/rollup.ts +++ b/packages/monorepo-tools/src/rollup.ts @@ -134,10 +134,14 @@ export function generateRollupOptions( ...packageJson.publishConfig, }) .map(([key, value]) => ({ key, value })) - .filter((item): item is { - key: 'main' | 'module' | 'types' | 'unpkg' - value: string - } => /^(main|module|unpkg|types)$/.test(item.key)) + .filter( + ( + item, + ): item is { + key: 'main' | 'module' | 'types' | 'unpkg' + value: string + } => /^(main|module|unpkg|types)$/.test(item.key), + ) .map(({ key: type, value: file }) => ({ file: file, format: diff --git a/packages/projectconfig/src/project/FilesystemHost.ts b/packages/projectconfig/src/project/FilesystemHost.ts index 17967c69..b26ba5d8 100644 --- a/packages/projectconfig/src/project/FilesystemHost.ts +++ b/packages/projectconfig/src/project/FilesystemHost.ts @@ -1,4 +1,4 @@ -import Path from 'path' +import * as Path from 'path' import { toPosixPath } from '@vuedx/shared' export interface FileWatcher { diff --git a/packages/projectconfig/src/project/VueProject.ts b/packages/projectconfig/src/project/VueProject.ts index f08dbb59..c95a4128 100644 --- a/packages/projectconfig/src/project/VueProject.ts +++ b/packages/projectconfig/src/project/VueProject.ts @@ -12,8 +12,8 @@ import { } from './FilesystemHost' import { resolveComponents } from './resolveComponents' import { resolveDirectives } from './resolveDirectives' -import JSON5 from 'json5' -import Path from 'path' +import * as JSON5 from 'json5' +import * as Path from 'path' export class VueProject { static create(fs: FilesystemHost, rootDir: string): VueProject { diff --git a/packages/transforms/src/index.ts b/packages/transforms/src/index.ts index b6f4818c..76e8017c 100644 --- a/packages/transforms/src/index.ts +++ b/packages/transforms/src/index.ts @@ -1,6 +1,10 @@ import * as T from '@babel/types' -import template from '@babel/template' -import generator, { GeneratorResult, GeneratorOptions } from '@babel/generator' +import * as template from '@babel/template' +import { + GeneratorResult, + GeneratorOptions, + CodeGenerator, +} from '@babel/generator' import { parse, ParserOptions } from '@babel/parser' import MagicString from 'magic-string' @@ -69,10 +73,10 @@ export function toCode( ), ) - const result = generator(statement as any, { + const result = new CodeGenerator(statement as any, { comments: true, ...options, - }) + }).generate() if (sourceText == null) return result @@ -218,7 +222,7 @@ export const createExportDeclarationForComponent = memoizeByFirstArg( return T.exportNamedDeclaration(statement) function createDeclarationForScriptSetup(): any { - const createExpr = template( + const createExpr = template.statement( `const ${config.exportName} = ${config.defineComponent}( %%props%%, %%emits%%, @@ -249,7 +253,7 @@ export const createExportDeclarationForComponent = memoizeByFirstArg( return createExpr({ props, emits, bindings, extra }) } function createDeclarationForScript(): any { - const createExpr = template( + const createExpr = template.statement( `const ${config.exportName} = ${config.defineComponent}(%%options%%)`, ) @@ -485,7 +489,9 @@ function createExportDeclarationFor( ...options, } - const createExpr = template(`const ${config.exportName} = %%value%%;`) + const createExpr = template.statement( + `const ${config.exportName} = %%value%%;`, + ) const declaration = createExpr({ value: getExpressionOrReference(findTargetExpression(), config), }) diff --git a/packages/vue-virtual-textdocument/src/BlockTransformer.ts b/packages/vue-virtual-textdocument/src/BlockTransformer.ts index 91eddb71..ed571b97 100644 --- a/packages/vue-virtual-textdocument/src/BlockTransformer.ts +++ b/packages/vue-virtual-textdocument/src/BlockTransformer.ts @@ -172,6 +172,9 @@ export const builtins: Record<'script' | 'template', BlockTransformer> = { 'export const __VueDX_directives = {};', 'export const __VueDX_expose = {};', 'export const __VueDX_DefineComponent = VueDX.internal.defineComponent({});', + `/* Error: ${(error as Error).message} ${ + (error as Error).stack ?? '' + } */`, annotations.diagnosticsIgnore.end, )), errors: [],