Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: intlify/bundle-tools
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 37fe89044985fb9b6e8eaa838ddcf29337428523
Choose a base ref
...
head repository: intlify/bundle-tools
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 119b12d651a5ff100df149e11666ffe586d4a84b
Choose a head ref
  • 6 commits
  • 27 files changed
  • 1 contributor

Commits on Mar 26, 2024

  1. breaking: drop deprecation code (#353)

    * breaking: drop deprecation code
    
    * more drop
    
    * update snapshots
    
    * more droping
    kazupon authored Mar 26, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    5165c1d View commit details
  2. breaking: drop legacy compatible features for Vue 2 (#354)

    * breaking: drop legacy compatible features for Vue 2
    
    * update lock file
    kazupon authored Mar 26, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    4ecd69d View commit details
  3. release: bundle-utils@8.0.0

    kazupon committed Mar 26, 2024
    Copy the full SHA
    7461b48 View commit details
  4. fix: upgrade bundle/utils deps version (#355)

    kazupon authored Mar 26, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    7f75c41 View commit details
  5. chore: code maintenance

    kazupon committed Mar 26, 2024
    Copy the full SHA
    8266a07 View commit details
  6. release: unplugin-vue-i18n@4.0.0

    kazupon committed Mar 26, 2024
    Copy the full SHA
    119b12d View commit details
Showing with 82 additions and 1,700 deletions.
  1. +9 −0 packages/bundle-utils/CHANGELOG.md
  2. +1 −2 packages/bundle-utils/package.json
  3. +0 −12 packages/bundle-utils/src/deps.ts
  4. +1 −5 packages/bundle-utils/src/index.ts
  5. +6 −37 packages/bundle-utils/src/js.ts
  6. +7 −58 packages/bundle-utils/src/json.ts
  7. +0 −24 packages/bundle-utils/src/legacy.ts
  8. +7 −58 packages/bundle-utils/src/yaml.ts
  9. +1 −10 packages/bundle-utils/test/deps.test.ts
  10. +0 −110 packages/bundle-utils/test/generator/__snapshots__/js.test.ts.snap
  11. +0 −473 packages/bundle-utils/test/generator/__snapshots__/json.test.ts.snap
  12. +0 −303 packages/bundle-utils/test/generator/__snapshots__/yaml.test.ts.snap
  13. +6 −67 packages/bundle-utils/test/generator/js.test.ts
  14. +0 −13 packages/bundle-utils/test/generator/js1.test.ts
  15. +9 −148 packages/bundle-utils/test/generator/json.test.ts
  16. +5 −83 packages/bundle-utils/test/generator/yaml.test.ts
  17. +0 −23 packages/bundle-utils/test/legacy.test.ts
  18. +18 −0 packages/unplugin-vue-i18n/CHANGELOG.md
  19. +0 −47 packages/unplugin-vue-i18n/README.md
  20. +2 −2 packages/unplugin-vue-i18n/package.json
  21. +8 −116 packages/unplugin-vue-i18n/src/index.ts
  22. +0 −6 packages/unplugin-vue-i18n/src/types.ts
  23. +0 −20 packages/unplugin-vue-i18n/test/vite/__snapshots__/custom-block.test.ts.snap
  24. +0 −17 packages/unplugin-vue-i18n/test/vite/custom-block.test.ts
  25. +0 −39 packages/unplugin-vue-i18n/test/webpack/__snapshots__/bridge.test.ts.snap
  26. +0 −24 packages/unplugin-vue-i18n/test/webpack/bridge.test.ts
  27. +2 −3 yarn.lock
9 changes: 9 additions & 0 deletions packages/bundle-utils/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@

## @intlify/bundle-utils@8.0.0 (2024-03-26)

#### :boom: Breaking Change
* [#354](https://github.com/intlify/bundle-tools/pull/354) breaking: drop legacy compatible features for Vue 2 ([@kazupon](https://github.com/kazupon))

#### Committers: 1
- kazuya kawaguchi ([@kazupon](https://github.com/kazupon))


## @intlify/bundle-utils@7.5.1 (2024-02-29)

#### :zap: Improvement Features
3 changes: 1 addition & 2 deletions packages/bundle-utils/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@intlify/bundle-utils",
"description": "Bundle utilities for Intlify project",
"version": "7.5.1",
"version": "8.0.0",
"author": {
"name": "kazuya kawaguchi",
"email": "kawakazu80@gmail.com"
@@ -24,7 +24,6 @@
"escodegen": "^2.1.0",
"estree-walker": "^2.0.2",
"jsonc-eslint-parser": "^2.3.0",
"magic-string": "^0.30.0",
"mlly": "^1.2.0",
"source-map-js": "^1.0.1",
"yaml-eslint-parser": "^1.2.2"
12 changes: 0 additions & 12 deletions packages/bundle-utils/src/deps.ts
Original file line number Diff line number Diff line change
@@ -36,18 +36,6 @@ export function checkInstallPackage(
)
}

// eslint-disable-next-line @typescript-eslint/ban-types
export function checkVueI18nBridgeInstallPackage(debug: Function): boolean {
let ret = false
try {
debug(`vue-i18n-bridge load path: ${_require.resolve('vue-i18n-bridge')}`)
ret = true
} catch (e) {
debug(`cannot find 'vue-i18n-bridge'`, e)
}
return ret
}

type VueI18nVersion = '8' | '9' | 'unknown' | ''

export function getVueI18nVersion(debug: Function): VueI18nVersion {
6 changes: 1 addition & 5 deletions packages/bundle-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
export { generate as generateJSON } from './json'
export { generate as generateYAML } from './yaml'
export { generate as generateJavaScript } from './js'
export {
getVueI18nVersion,
checkInstallPackage,
checkVueI18nBridgeInstallPackage
} from './deps'
export { getVueI18nVersion, checkInstallPackage } from './deps'
export type { CodeGenOptions, CodeGenResult, DevEnv } from './codegen'
export type { InstalledPackage } from './deps'
43 changes: 6 additions & 37 deletions packages/bundle-utils/src/js.ts
Original file line number Diff line number Diff line change
@@ -29,8 +29,6 @@ export function generate(
targetSource: string | Buffer,
{
type = 'plain',
bridge = false,
exportESM = false,
filename = 'vue-i18n-loader.js',
inSourceMap = undefined,
locale = '',
@@ -44,8 +42,7 @@ export function generate(
useClassComponent = false,
allowDynamic = false,
jit = false
}: CodeGenOptions,
injector?: () => string
}: CodeGenOptions
): CodeGenResult<Node> {
const target = Buffer.isBuffer(targetSource)
? targetSource.toString()
@@ -54,8 +51,6 @@ export function generate(

const options = {
type,
bridge,
exportESM,
source: value,
sourceMap,
locale,
@@ -109,7 +104,7 @@ export function generate(
}
}

const codeMaps = _generate(generator, ast, options, injector)
const codeMaps = _generate(generator, ast, options)

const { code, map } = generator.context()
// if (map) {
@@ -155,25 +150,15 @@ function scanAst(ast: Node) {
function _generate(
generator: CodeGenerator,
node: Node,
options: CodeGenOptions = {},
injector?: () => string
options: CodeGenOptions = {}
): Map<string, RawSourceMap> {
const propsCountStack = [] as number[]
const pathStack = [] as string[]
const itemsCountStack = [] as number[]
const skipStack = [] as boolean[]
const { forceStringify } = generator.context()
const codeMaps = new Map<string, RawSourceMap>()
const {
type,
bridge,
exportESM,
sourceMap,
isGlobal,
locale,
useClassComponent,
jit
} = options
const { type, sourceMap, isGlobal, locale, useClassComponent, jit } = options

const codegenFn: CodeGenFunction = jit
? generateResourceAst
@@ -200,17 +185,11 @@ function _generate(
type === 'sfc' ? (!isGlobal ? '__i18n' : '__i18nGlobal') : ''
const localeName =
type === 'sfc' ? (locale != null ? locale : `""`) : ''
const exportSyntax = bridge
? exportESM
? `export default`
: `module.exports =`
: `export default`
const exportSyntax = 'export default'
generator.push(`${exportSyntax} function (Component) {`)
generator.indent()
// prettier-ignore
const componentVariable = bridge
? `Component.options || Component`
: useClassComponent
const componentVariable = useClassComponent
? `Component.__o || Component.__vccOpts || Component`
: `Component`
// prettier-ignore
@@ -383,16 +362,6 @@ function _generate(
if (type === 'sfc') {
generator.deindent()
generator.push(`})`)
if (bridge && injector) {
generator.newline()
generator.pushline(
`${componentNamespace}.__i18nBridge = ${componentNamespace}.__i18nBridge || []`
)
generator.pushline(
`${componentNamespace}.__i18nBridge.push('${injector()}')`
)
generator.pushline(`delete ${componentNamespace}._Ctor`)
}
generator.deindent()
generator.pushline(`}`)
} else if (type === 'plain') {
65 changes: 7 additions & 58 deletions packages/bundle-utils/src/json.ts
Original file line number Diff line number Diff line change
@@ -7,16 +7,14 @@ import {
traverseNodes,
getStaticJSONValue
} from 'jsonc-eslint-parser'
import { isString, friendlyJSONstringify } from '@intlify/shared'
import { isString } from '@intlify/shared'
import {
createCodeGenerator,
generateMessageFunction,
generateResourceAst,
mapLinesColumns,
excludeLocales
} from './codegen'
import { generateLegacyCode } from './legacy'
import MagicString from 'magic-string'

import type { RawSourceMap } from 'source-map-js'
import type { JSONProgram, JSONNode } from 'jsonc-eslint-parser/lib/parser/ast'
@@ -31,11 +29,7 @@ export function generate(
targetSource: string | Buffer,
{
type = 'plain',
legacy = false,
vueVersion = 'v2.6',
bridge = false,
onlyLocales = [],
exportESM = false,
filename = 'vue-i18n-loader.json',
inSourceMap = undefined,
locale = '',
@@ -48,8 +42,7 @@ export function generate(
escapeHtml = false,
useClassComponent = false,
jit = false
}: CodeGenOptions,
injector?: () => string
}: CodeGenOptions
): CodeGenResult<JSONProgram> {
let value = Buffer.isBuffer(targetSource)
? targetSource.toString()
@@ -60,8 +53,6 @@ export function generate(

const options = {
type,
bridge,
exportESM,
source: value,
sourceMap,
locale,
@@ -92,23 +83,7 @@ export function generate(
ast = parseJSON(value, { filePath: filename })
}

// for vue 2.x
if (legacy && type === 'sfc') {
const gen = () => friendlyJSONstringify(getStaticJSONValue(ast))
const code = generateLegacyCode({ isGlobal, vueVersion }, gen)
const s = new MagicString(code)
return {
ast,
code: s.toString(),
map: s.generateMap({
file: filename,
source: value,
includeContent: true
}) as unknown as RawSourceMap
}
}

const codeMaps = _generate(generator, ast, options, injector)
const codeMaps = _generate(generator, ast, options)

const { code, map } = generator.context()
// if (map) {
@@ -132,24 +107,14 @@ export function generate(
function _generate(
generator: CodeGenerator,
node: JSONProgram,
options: CodeGenOptions = {},
injector?: () => string
options: CodeGenOptions = {}
): Map<string, RawSourceMap> {
const propsCountStack = [] as number[]
const pathStack = [] as string[]
const itemsCountStack = [] as number[]
const { forceStringify } = generator.context()
const codeMaps = new Map<string, RawSourceMap>()
const {
type,
bridge,
exportESM,
sourceMap,
isGlobal,
locale,
useClassComponent,
jit
} = options
const { type, sourceMap, isGlobal, locale, useClassComponent, jit } = options

const codegenFn: CodeGenFunction = jit
? generateResourceAst
@@ -169,17 +134,11 @@ function _generate(
type === 'sfc' ? (!isGlobal ? '__i18n' : '__i18nGlobal') : ''
const localeName =
type === 'sfc' ? (locale != null ? locale : `""`) : ''
const exportSyntax = bridge
? exportESM
? `export default`
: `module.exports =`
: `export default`
const exportSyntax = 'export default'
generator.push(`${exportSyntax} function (Component) {`)
generator.indent()
// prettier-ignore
const componentVariable = bridge
? `Component.options || Component`
: useClassComponent
const componentVariable = useClassComponent
? `Component.__o || Component.__vccOpts || Component`
: `Component`
// prettier-ignore
@@ -297,16 +256,6 @@ function _generate(
if (type === 'sfc') {
generator.deindent()
generator.push(`})`)
if (bridge && injector) {
generator.newline()
generator.pushline(
`${componentNamespace}.__i18nBridge = ${componentNamespace}.__i18nBridge || []`
)
generator.pushline(
`${componentNamespace}.__i18nBridge.push('${injector()}')`
)
generator.pushline(`delete ${componentNamespace}._Ctor`)
}
generator.deindent()
generator.pushline(`}`)
} else if (type === 'plain') {
24 changes: 0 additions & 24 deletions packages/bundle-utils/src/legacy.ts

This file was deleted.

Loading