@intlify/bundle-utils 7.0.1 → 7.0.2
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/lib/index.cjs +15 -15
- package/lib/index.mjs +3 -8
- package/package.json +4 -4
package/lib/index.cjs
CHANGED
|
@@ -2,20 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
const jsoncEslintParser = require('jsonc-eslint-parser');
|
|
4
4
|
const shared = require('@intlify/shared');
|
|
5
|
-
const module$1 = require('node:module');
|
|
6
5
|
const sourceMapJs = require('source-map-js');
|
|
6
|
+
const messageCompiler = require('@intlify/message-compiler');
|
|
7
7
|
const MagicString = require('magic-string');
|
|
8
8
|
const yamlEslintParser = require('yaml-eslint-parser');
|
|
9
9
|
const acorn = require('acorn');
|
|
10
10
|
const escodegen = require('escodegen');
|
|
11
11
|
const estreeWalker = require('estree-walker');
|
|
12
|
+
const module$1 = require('node:module');
|
|
13
|
+
|
|
14
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
15
|
+
|
|
16
|
+
const MagicString__default = /*#__PURE__*/_interopDefaultCompat(MagicString);
|
|
17
|
+
const module__default = /*#__PURE__*/_interopDefaultCompat(module$1);
|
|
12
18
|
|
|
13
|
-
const require$1 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
14
|
-
const {
|
|
15
|
-
baseCompile,
|
|
16
|
-
detectHtmlTag,
|
|
17
|
-
LocationStub
|
|
18
|
-
} = require$1("@intlify/message-compiler");
|
|
19
19
|
function createCodeGenerator(options = {
|
|
20
20
|
filename: "bundle.json",
|
|
21
21
|
sourceMap: false,
|
|
@@ -38,7 +38,7 @@ function createCodeGenerator(options = {
|
|
|
38
38
|
function push(code, node, name) {
|
|
39
39
|
_context.code += code;
|
|
40
40
|
if (_context.map && node) {
|
|
41
|
-
if (node.loc && node.loc !==
|
|
41
|
+
if (node.loc && node.loc !== messageCompiler.LOCATION_STUB) {
|
|
42
42
|
addMapping(node.loc.start, name);
|
|
43
43
|
}
|
|
44
44
|
advancePositionWithSource(_context, code);
|
|
@@ -119,7 +119,7 @@ function generateMessageFunction(msg, options = {}, path) {
|
|
|
119
119
|
const onError = options.onError || ON_ERROR_NOOP;
|
|
120
120
|
const errors = [];
|
|
121
121
|
let detecteHtmlInMsg = false;
|
|
122
|
-
if (detectHtmlTag(msg)) {
|
|
122
|
+
if (messageCompiler.detectHtmlTag(msg)) {
|
|
123
123
|
detecteHtmlInMsg = true;
|
|
124
124
|
if (strictMessage) {
|
|
125
125
|
const errMsg = shared.format(DETECT_MESSAGE, { msg });
|
|
@@ -144,7 +144,7 @@ function generateMessageFunction(msg, options = {}, path) {
|
|
|
144
144
|
errors.push(err);
|
|
145
145
|
}
|
|
146
146
|
};
|
|
147
|
-
const { code, ast, map } = baseCompile(_msg, newOptions);
|
|
147
|
+
const { code, ast, map } = messageCompiler.baseCompile(_msg, newOptions);
|
|
148
148
|
const occured = errors.length > 0;
|
|
149
149
|
const genCode = !occured ? env === "development" ? `(()=>{const fn=${code};fn.source=${JSON.stringify(msg)};return fn;})()` : `${code}` : `\`${_msg}\``;
|
|
150
150
|
return { code: genCode, ast, map, errors };
|
|
@@ -222,7 +222,7 @@ function generateResourceAst(msg, options = {}, path) {
|
|
|
222
222
|
const onError = options.onError || ON_ERROR_NOOP;
|
|
223
223
|
const errors = [];
|
|
224
224
|
let detecteHtmlInMsg = false;
|
|
225
|
-
if (detectHtmlTag(msg)) {
|
|
225
|
+
if (messageCompiler.detectHtmlTag(msg)) {
|
|
226
226
|
detecteHtmlInMsg = true;
|
|
227
227
|
if (strictMessage) {
|
|
228
228
|
const errMsg = shared.format(DETECT_MESSAGE, { msg });
|
|
@@ -253,7 +253,7 @@ function generateResourceAst(msg, options = {}, path) {
|
|
|
253
253
|
errors.push(err);
|
|
254
254
|
}
|
|
255
255
|
};
|
|
256
|
-
const { ast, map } = baseCompile(_msg, newOptions);
|
|
256
|
+
const { ast, map } = messageCompiler.baseCompile(_msg, newOptions);
|
|
257
257
|
const occured = errors.length > 0;
|
|
258
258
|
const code = !occured ? `${shared.friendlyJSONstringify(ast)}` : `\`${_msg}\``;
|
|
259
259
|
return { code, ast, map, errors };
|
|
@@ -316,7 +316,7 @@ function generate$2(targetSource, {
|
|
|
316
316
|
if (legacy && type === "sfc") {
|
|
317
317
|
const gen = () => shared.friendlyJSONstringify(jsoncEslintParser.getStaticJSONValue(ast));
|
|
318
318
|
const code2 = generateLegacyCode(options, gen);
|
|
319
|
-
const s = new
|
|
319
|
+
const s = new MagicString__default(code2);
|
|
320
320
|
return {
|
|
321
321
|
ast,
|
|
322
322
|
code: s.toString(),
|
|
@@ -575,7 +575,7 @@ function generate$1(targetSource, {
|
|
|
575
575
|
if (legacy && type === "sfc") {
|
|
576
576
|
const gen = () => shared.friendlyJSONstringify(yamlEslintParser.getStaticYAMLValue(ast));
|
|
577
577
|
const code2 = generateLegacyCode(options, gen);
|
|
578
|
-
const s = new
|
|
578
|
+
const s = new MagicString__default(code2);
|
|
579
579
|
return {
|
|
580
580
|
ast,
|
|
581
581
|
code: s.toString(),
|
|
@@ -1146,7 +1146,7 @@ function getValue(node) {
|
|
|
1146
1146
|
return node.type === "Literal" ? node.value : node.type === "TemplateLiteral" ? node.quasis.map((quasi) => quasi.value.cooked).join("") : void 0;
|
|
1147
1147
|
}
|
|
1148
1148
|
|
|
1149
|
-
const _require =
|
|
1149
|
+
const _require = module__default.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (document.currentScript && document.currentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
1150
1150
|
function checkInstallPackage(pkg, debug) {
|
|
1151
1151
|
let installedVueI18n = false;
|
|
1152
1152
|
try {
|
package/lib/index.mjs
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import { parseJSON, traverseNodes, getStaticJSONValue } from 'jsonc-eslint-parser';
|
|
2
2
|
import { isBoolean, format, escapeHtml, friendlyJSONstringify, isString, isNumber } from '@intlify/shared';
|
|
3
|
-
import module from 'node:module';
|
|
4
3
|
import { SourceMapGenerator, SourceMapConsumer } from 'source-map-js';
|
|
4
|
+
import { LOCATION_STUB, detectHtmlTag, baseCompile } from '@intlify/message-compiler';
|
|
5
5
|
import MagicString from 'magic-string';
|
|
6
6
|
import { parseYAML, traverseNodes as traverseNodes$1, getStaticYAMLValue } from 'yaml-eslint-parser';
|
|
7
7
|
import { parse } from 'acorn';
|
|
8
8
|
import { generate as generate$3 } from 'escodegen';
|
|
9
9
|
import { walk } from 'estree-walker';
|
|
10
|
+
import module from 'node:module';
|
|
10
11
|
|
|
11
|
-
const require = module.createRequire(import.meta.url);
|
|
12
|
-
const {
|
|
13
|
-
baseCompile,
|
|
14
|
-
detectHtmlTag,
|
|
15
|
-
LocationStub
|
|
16
|
-
} = require("@intlify/message-compiler");
|
|
17
12
|
function createCodeGenerator(options = {
|
|
18
13
|
filename: "bundle.json",
|
|
19
14
|
sourceMap: false,
|
|
@@ -36,7 +31,7 @@ function createCodeGenerator(options = {
|
|
|
36
31
|
function push(code, node, name) {
|
|
37
32
|
_context.code += code;
|
|
38
33
|
if (_context.map && node) {
|
|
39
|
-
if (node.loc && node.loc !==
|
|
34
|
+
if (node.loc && node.loc !== LOCATION_STUB) {
|
|
40
35
|
addMapping(node.loc.start, name);
|
|
41
36
|
}
|
|
42
37
|
advancePositionWithSource(_context, code);
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlify/bundle-utils",
|
|
3
3
|
"description": "Bundle utilities for Intlify project",
|
|
4
|
-
"version": "7.0.
|
|
4
|
+
"version": "7.0.2",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "kazuya kawaguchi",
|
|
7
7
|
"email": "kawakazu80@gmail.com"
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@intlify/message-compiler": "9.3.0-beta.
|
|
22
|
-
"@intlify/shared": "9.3.0-beta.
|
|
21
|
+
"@intlify/message-compiler": "9.3.0-beta.24",
|
|
22
|
+
"@intlify/shared": "9.3.0-beta.24",
|
|
23
23
|
"acorn": "^8.8.2",
|
|
24
24
|
"escodegen": "^2.0.0",
|
|
25
25
|
"estree-walker": "^2.0.2",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/escodegen": "^0.0.7",
|
|
34
34
|
"@types/estree": "^1.0.0",
|
|
35
|
-
"unbuild": "^1.1
|
|
35
|
+
"unbuild": "^1.2.1"
|
|
36
36
|
},
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">= 14.16"
|