Skip to content

Commit

Permalink
fix bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
znck committed Apr 27, 2022
1 parent 763807d commit 1dc5763
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 16 deletions.
2 changes: 1 addition & 1 deletion extensions/vscode-vue-language-features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion extensions/vscode-vue/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions packages/monorepo-tools/src/rollup-plugin-esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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],
Expand Down
12 changes: 8 additions & 4 deletions packages/monorepo-tools/src/rollup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExtendedOutputOptions>(({ key: type, value: file }) => ({
file: file,
format:
Expand Down
2 changes: 1 addition & 1 deletion packages/projectconfig/src/project/FilesystemHost.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Path from 'path'
import * as Path from 'path'
import { toPosixPath } from '@vuedx/shared'

export interface FileWatcher {
Expand Down
4 changes: 2 additions & 2 deletions packages/projectconfig/src/project/VueProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
20 changes: 13 additions & 7 deletions packages/transforms/src/index.ts
Original file line number Diff line number Diff line change
@@ -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'

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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%%,
Expand Down Expand Up @@ -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%%)`,
)

Expand Down Expand Up @@ -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),
})
Expand Down
3 changes: 3 additions & 0 deletions packages/vue-virtual-textdocument/src/BlockTransformer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: [],
Expand Down

0 comments on commit 1dc5763

Please sign in to comment.