Comments (1)
It seems that the output of the parse
function from vue/sfc-compiler
changed.
Consider the following example:
import { parse } from 'vue/compiler-sfc'
const { descriptor } = parse(`<script setup lang="ts">
import { useIntl } from 'vue-intl';
const intl = useIntl()
const messageHello = intl.formatMessage({ defaultMessage: 'Hello' })
</script>
<template>
<main>
{{ $formatMessage({ id: 'format this', defaultMessage: 'meh' }) }}
{{ messageHello }}, {{ intl.formatMessage({ defaultMessage: 'I just called to say…' }) }}
</main>
</template>
`, { filename: 'my-component.vue' })
const { template } = descriptor
console.log(template)
The output using [email protected]
is:
{
type: 'template',
content: '\n' +
' <main>\n' +
" {{ $formatMessage({ id: 'format this', defaultMessage: 'meh' }) }}\n" +
" {{ messageHello }}, {{ intl.formatMessage({ defaultMessage: 'I just called to say…' }) }}\n" +
' </main>\n',
loc: {
source: '\n' +
' <main>\n' +
" {{ $formatMessage({ id: 'format this', defaultMessage: 'meh' }) }}\n" +
" {{ messageHello }}, {{ intl.formatMessage({ defaultMessage: 'I just called to say…' }) }}\n" +
' </main>\n',
start: { column: 11, line: 9, offset: 176 },
end: { column: 1, line: 14, offset: 361 }
},
attrs: {},
ast: {
type: 1,
ns: 0,
tag: 'template',
tagType: 0,
props: [],
isSelfClosing: false,
children: [ [Object], [Object], [Object] ],
loc: {
start: [Object],
end: [Object],
source: '<template>\n' +
' <main>\n' +
" {{ $formatMessage({ id: 'format this', defaultMessage: 'meh' }) }}\n" +
" {{ messageHello }}, {{ intl.formatMessage({ defaultMessage: 'I just called to say…' }) }}\n" +
' </main>\n' +
'</template>'
},
codegenNode: undefined
},
map: {
version: 3,
sources: [ 'my-component.vue' ],
names: [],
mappings: ';EASE,CAAC,CAAC,CAAC,CAAC,CAAC;IACH,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACjE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;EAC1F,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC',
file: 'my-component.vue',
sourceRoot: '',
sourcesContent: [
'<script setup lang="ts">\n' +
"import { useIntl } from 'vue-intl';\n" +
'\n' +
'const intl = useIntl()\n' +
'\n' +
"const messageHello = intl.formatMessage({ defaultMessage: 'Hello' })\n" +
'</script>\n' +
'\n' +
'<template>\n' +
' <main>\n' +
" {{ $formatMessage({ id: 'format this', defaultMessage: 'meh' }) }}\n" +
" {{ messageHello }}, {{ intl.formatMessage({ defaultMessage: 'I just called to say…' }) }}\n" +
' </main>\n' +
'</template>\n'
]
}
}
While the output using [email protected]
is:
{
type: 'template',
content: '\n' +
' <main>\n' +
" {{ $formatMessage({ id: 'format this', defaultMessage: 'meh' }) }}\n" +
" {{ messageHello }}, {{ intl.formatMessage({ defaultMessage: 'I just called to say…' }) }}\n" +
' </main>\n',
loc: {
start: { column: 11, line: 9, offset: 176 },
end: { column: 1, line: 14, offset: 361 },
source: '\n' +
' <main>\n' +
" {{ $formatMessage({ id: 'format this', defaultMessage: 'meh' }) }}\n" +
" {{ messageHello }}, {{ intl.formatMessage({ defaultMessage: 'I just called to say…' }) }}\n" +
' </main>\n'
},
attrs: {},
ast: {
type: 0,
source: '<script setup lang="ts">\n' +
"import { useIntl } from 'vue-intl';\n" +
'\n' +
'const intl = useIntl()\n' +
'\n' +
"const messageHello = intl.formatMessage({ defaultMessage: 'Hello' })\n" +
'</script>\n' +
'\n' +
'<template>\n' +
' <main>\n' +
" {{ $formatMessage({ id: 'format this', defaultMessage: 'meh' }) }}\n" +
" {{ messageHello }}, {{ intl.formatMessage({ defaultMessage: 'I just called to say…' }) }}\n" +
' </main>\n' +
'</template>\n',
children: [ [Object] ],
helpers: Set(0) {},
components: [],
directives: [],
hoists: [],
imports: [],
cached: 0,
temps: 0,
codegenNode: undefined,
loc: { start: [Object], end: [Object], source: '' }
},
map: {
version: 3,
sources: [ 'my-component.vue' ],
names: [],
mappings: ';EASE,CAAC,CAAC,CAAC,CAAC,CAAC;IACH,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;IACjE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;EAC1F,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC',
file: 'my-component.vue',
sourceRoot: '',
sourcesContent: [
'<script setup lang="ts">\n' +
"import { useIntl } from 'vue-intl';\n" +
'\n' +
'const intl = useIntl()\n' +
'\n' +
"const messageHello = intl.formatMessage({ defaultMessage: 'Hello' })\n" +
'</script>\n' +
'\n' +
'<template>\n' +
' <main>\n' +
" {{ $formatMessage({ id: 'format this', defaultMessage: 'meh' }) }}\n" +
" {{ messageHello }}, {{ intl.formatMessage({ defaultMessage: 'I just called to say…' }) }}\n" +
' </main>\n' +
'</template>\n'
]
}
}
The value of the template.ast
key changed, and the current implementation of packages/cli-lib/src/vue_extractor.ts
isn't able to parse it properly.
from formatjs.
Related Issues (20)
- eslint-plugin-formatjs doesn't check `this.intl.formatMessage(...)` usages HOT 1
- `LocaleMatcher` doesn't work on propietary tags HOT 2
- Node 20.12.1 x Jest; shouldPolyfill results in RangeError. Incorrect locale information provided HOT 1
- eslint-plugin-formatjs and eslint v9 support HOT 5
- Website - search is broken
- @formatjs/intl-localematcher documentation is wrong... incorrect order HOT 1
- @formatjs/swc-plugin-experimental incompatible with latest SWC core version HOT 5
- cli-lib's `extract` function ignores `throws` setting for errors in `processFile`
- intl-localematcher: Incorrect locale information provided with '*' HOT 4
- Seemingly orphaned type `IntlLocaleLike` in icu-messageformat-parser
- Getting singular currency name seems unachievable. HOT 1
- [@formatjs/intl-durationformat] package.json wrong main entry
- extract messages with --flatten causes issues when there are multiple plural rules using hash placeholder HOT 1
- Forced polyfill of de-AT locale for Intl.NumberFormat is using incorrect currency group separator HOT 3
- Extracting arguments from messages using TypeScript HOT 1
- Abbreviated time zone name missing for America/Detroit HOT 3
- Allow parallel locale & polyfill loading HOT 1
- Slow module initialization time on low-end devices HOT 9
- `@formatjs/intl-localematcher`: Order of items in `availableLocales` make a difference
- @formatjs/cli-lib.extract fails to find formatMessage calls when Types are provided and optional chaining are used together
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from formatjs.