Skip to content

Commit

Permalink
fix(unplugin-vue-i18n): support esm fully (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
kazupon authored Jul 8, 2023
1 parent 5815d62 commit cea80c7
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 19 deletions.
4 changes: 2 additions & 2 deletions packages/bundle-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
}
},
"dependencies": {
"@intlify/message-compiler": "9.3.0-beta.22",
"@intlify/shared": "9.3.0-beta.22",
"@intlify/message-compiler": "9.3.0-beta.24",
"@intlify/shared": "9.3.0-beta.24",
"acorn": "^8.8.2",
"escodegen": "^2.0.0",
"estree-walker": "^2.0.2",
Expand Down
16 changes: 6 additions & 10 deletions packages/bundle-utils/src/codegen.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import module from 'node:module'
import { SourceMapGenerator, SourceMapConsumer } from 'source-map-js'
import {
format,
escapeHtml as sanitizeHtml,
isBoolean,
friendlyJSONstringify
} from '@intlify/shared'
import {
baseCompile,
detectHtmlTag,
LOCATION_STUB
} from '@intlify/message-compiler'

import type { RawSourceMap, MappedPosition, MappingItem } from 'source-map-js'
import type {
Expand All @@ -14,14 +18,6 @@ import type {
CompileOptions
} from '@intlify/message-compiler'

// NOTE: use sourcemap (currently, `@intlify/message-compiler` support cjs pkg only)
const require = module.createRequire(import.meta.url)
const {
baseCompile,
detectHtmlTag,
LocationStub
} = require('@intlify/message-compiler')

/**
* Compilation dev environments
*
Expand Down Expand Up @@ -150,7 +146,7 @@ export function createCodeGenerator(
): void {
_context.code += code
if (_context.map && node) {
if (node.loc && node.loc !== LocationStub) {
if (node.loc && node.loc !== LOCATION_STUB) {
addMapping(node.loc.start, name)
}
advancePositionWithSource(_context as Position, code)
Expand Down
21 changes: 14 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1133,8 +1133,8 @@ __metadata:
version: 0.0.0-use.local
resolution: "@intlify/bundle-utils@workspace:packages/bundle-utils"
dependencies:
"@intlify/message-compiler": 9.3.0-beta.22
"@intlify/shared": 9.3.0-beta.22
"@intlify/message-compiler": 9.3.0-beta.24
"@intlify/shared": 9.3.0-beta.24
"@types/escodegen": ^0.0.7
"@types/estree": ^1.0.0
acorn: ^8.8.2
Expand Down Expand Up @@ -1221,13 +1221,13 @@ __metadata:
languageName: node
linkType: hard

"@intlify/message-compiler@npm:9.3.0-beta.22":
version: 9.3.0-beta.22
resolution: "@intlify/message-compiler@npm:9.3.0-beta.22"
"@intlify/message-compiler@npm:9.3.0-beta.24":
version: 9.3.0-beta.24
resolution: "@intlify/message-compiler@npm:9.3.0-beta.24"
dependencies:
"@intlify/shared": 9.3.0-beta.22
"@intlify/shared": 9.3.0-beta.24
source-map-js: ^1.0.2
checksum: a6e55e3624a4de7521ddb94b832baf9f1030aa8c5692d0b62dcd59734c91f093d486dc969af9d121119986b1a9810a053052c3af0b0bfb92d287d1e6ae23e961
checksum: 780a35df65dea03e94ec0303820fdd03684d9ef3c942a6c47a792d51620a6ffab8975919482f26023d1b8115fd01e40b397d558cf779febc6af9e0c889208d2c
languageName: node
linkType: hard

Expand Down Expand Up @@ -1282,6 +1282,13 @@ __metadata:
languageName: node
linkType: hard

"@intlify/shared@npm:9.3.0-beta.24":
version: 9.3.0-beta.24
resolution: "@intlify/shared@npm:9.3.0-beta.24"
checksum: be23a68c5d5674defef43f98eb264f5878431ac38fae81f71be059b178adf4095de7b9f0d4935e001033a7450bacebc0aacf27f5904eadd8ff71ec4ff6a7ad1e
languageName: node
linkType: hard

"@intlify/shared@npm:^9.2.2":
version: 9.2.2
resolution: "@intlify/shared@npm:9.2.2"
Expand Down

0 comments on commit cea80c7

Please sign in to comment.