@lingui/extractor-vue 4.0.0 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -16,12 +16,13 @@ npm install --save-dev @lingui/extractor-vue
16
16
 
17
17
  ## Usage
18
18
 
19
- This custom extractor requires that you use JavaScript for your Lingui configuration.
19
+ This custom extractor requires that you use JavaScript or TypeScript for your Lingui configuration.
20
20
 
21
21
  ```js
22
22
  import { vueExtractor } from "@lingui/extractor-vue"
23
- import babel from "@lingui/cli/api/extractors/babel"
23
+ import { extractor as defaultExtractor } from "@lingui/cli/api"
24
24
 
25
+ /** @type {import('@lingui/conf').LinguiConfig} */
25
26
  const linguiConfig = {
26
27
  locales: ["en", "nb"],
27
28
  sourceLocale: "en",
@@ -31,7 +32,7 @@ const linguiConfig = {
31
32
  include: ["<rootDir>/src"],
32
33
  },
33
34
  ],
34
- extractors: [babel, vueExtractor],
35
+ extractors: [defaultExtractor, vueExtractor],
35
36
  }
36
37
 
37
38
  export default linguiConfig
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const compilerSfc = require('@vue/compiler-sfc');
4
- const babel = require('@lingui/cli/api/extractors/babel');
4
+ const api = require('@lingui/cli/api');
5
5
 
6
6
  const vueExtractor = {
7
7
  match(filename) {
@@ -13,13 +13,16 @@ const vueExtractor = {
13
13
  filename,
14
14
  ignoreEmpty: true
15
15
  });
16
- const compiledTemplate = compilerSfc.compileTemplate({
16
+ const isTsBlock = (block) => block?.lang === "ts";
17
+ const compiledTemplate = descriptor.template && compilerSfc.compileTemplate({
17
18
  source: descriptor.template.content,
18
19
  filename,
19
20
  inMap: descriptor.template.map,
20
- id: filename
21
+ id: filename,
22
+ compilerOptions: {
23
+ isTS: isTsBlock(descriptor.script) || isTsBlock(descriptor.scriptSetup)
24
+ }
21
25
  });
22
- const isTsBlock = (block) => block?.lang === "ts";
23
26
  const targets = [
24
27
  [
25
28
  descriptor.script?.content,
@@ -39,7 +42,7 @@ const vueExtractor = {
39
42
  ];
40
43
  await Promise.all(
41
44
  targets.filter(([source]) => Boolean(source)).map(
42
- ([source, map, isTs]) => babel.extract(
45
+ ([source, map, isTs]) => api.extractor.extract(
43
46
  filename + (isTs ? ".ts" : ""),
44
47
  source,
45
48
  onMessageExtracted,
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  import { parse, compileTemplate } from '@vue/compiler-sfc';
2
- import babel from '@lingui/cli/api/extractors/babel';
2
+ import { extractor } from '@lingui/cli/api';
3
3
 
4
4
  const vueExtractor = {
5
5
  match(filename) {
@@ -11,13 +11,16 @@ const vueExtractor = {
11
11
  filename,
12
12
  ignoreEmpty: true
13
13
  });
14
- const compiledTemplate = compileTemplate({
14
+ const isTsBlock = (block) => block?.lang === "ts";
15
+ const compiledTemplate = descriptor.template && compileTemplate({
15
16
  source: descriptor.template.content,
16
17
  filename,
17
18
  inMap: descriptor.template.map,
18
- id: filename
19
+ id: filename,
20
+ compilerOptions: {
21
+ isTS: isTsBlock(descriptor.script) || isTsBlock(descriptor.scriptSetup)
22
+ }
19
23
  });
20
- const isTsBlock = (block) => block?.lang === "ts";
21
24
  const targets = [
22
25
  [
23
26
  descriptor.script?.content,
@@ -37,7 +40,7 @@ const vueExtractor = {
37
40
  ];
38
41
  await Promise.all(
39
42
  targets.filter(([source]) => Boolean(source)).map(
40
- ([source, map, isTs]) => babel.extract(
43
+ ([source, map, isTs]) => extractor.extract(
41
44
  filename + (isTs ? ".ts" : ""),
42
45
  source,
43
46
  onMessageExtracted,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lingui/extractor-vue",
3
- "version": "4.0.0",
3
+ "version": "4.1.0",
4
4
  "description": "Custom Vue.js extractor to be used with the CLI tool",
5
5
  "main": "./dist/index.cjs",
6
6
  "module": "./dist/index.mjs",
@@ -35,13 +35,13 @@
35
35
  "/dist"
36
36
  ],
37
37
  "dependencies": {
38
- "@lingui/cli": "4.0.0",
39
- "@lingui/conf": "4.0.0",
38
+ "@lingui/cli": "4.1.0",
39
+ "@lingui/conf": "4.1.0",
40
40
  "@vue/compiler-sfc": "^3.2.47"
41
41
  },
42
42
  "devDependencies": {
43
- "@lingui/babel-plugin-extract-messages": "4.0.0",
43
+ "@lingui/babel-plugin-extract-messages": "4.1.0",
44
44
  "unbuild": "^1.1.2"
45
45
  },
46
- "gitHead": "998996381f5e5a458c2eccf650f949d8c5d8ac89"
46
+ "gitHead": "471813c5de9ade3acccf647e18922b570a804577"
47
47
  }