Skip to content

Commit e2af5ed

Browse files
committed
📦 build: generate dist files
1 parent 63b6ec3 commit e2af5ed

File tree

3 files changed

+9
-28
lines changed

3 files changed

+9
-28
lines changed

lib/infuser.js

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
"use strict";
2-
var __importDefault = (this && this.__importDefault) || function (mod) {
3-
return (mod && mod.__esModule) ? mod : { "default": mod };
4-
};
52
Object.defineProperty(exports, "__esModule", { value: true });
63
const utils_1 = require("./utils");
7-
const prettier_1 = __importDefault(require("prettier"));
84
const debug_1 = require("debug");
95
const debug = debug_1.debug('vue-i18n-locale-message:infuser');
106
function infuse(basePath, sources, meta) {
@@ -26,7 +22,7 @@ function generate(meta, descriptor) {
2622
const content = buildContent(i18nBlocks, raw, blocks);
2723
debug(`build content:\n${content}`);
2824
debug(`content size: raw=${raw.length}, content=${content.length}`);
29-
return format(content, 'vue');
25+
return content;
3026
}
3127
function getBlocks(descriptor) {
3228
const { template, script, styles, customBlocks } = descriptor;
@@ -61,7 +57,7 @@ function buildContent(i18nBlocks, raw, blocks) {
6157
messages = utils_1.parseContent(block.content, lang);
6258
}
6359
contents = contents.concat(raw.slice(offset, block.start));
64-
const serialized = `\n${format(utils_1.stringfyContent(messages, lang), lang)}`;
60+
const serialized = `\n${utils_1.stringifyContent(messages, lang)}`;
6561
contents = contents.concat(serialized);
6662
offset = block.end;
6763
i18nBlockCounter++;
@@ -93,20 +89,5 @@ function buildI18nTag(i18nBlock) {
9389
tag += '>';
9490
return `\n
9591
${tag}
96-
${format(utils_1.stringfyContent(locale ? messages[locale] : messages, lang), lang)}</i18n>`;
97-
}
98-
function format(source, lang) {
99-
debug(`format: lang=${lang}, source=${source}`);
100-
switch (lang) {
101-
case 'vue':
102-
return source;
103-
case 'yaml':
104-
case 'yml':
105-
return prettier_1.default.format(source, { parser: 'yaml', tabWidth: 2 });
106-
case 'json5':
107-
return prettier_1.default.format(source, { parser: 'json5', tabWidth: 2 });
108-
case 'json':
109-
default:
110-
return prettier_1.default.format(source, { parser: 'json-stringify', tabWidth: 2 });
111-
}
92+
${utils_1.stringifyContent(locale ? messages[locale] : messages, lang)}</i18n>`;
11293
}

lib/squeezer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
33
const utils_1 = require("./utils");
44
const debug_1 = require("debug");
55
const debug = debug_1.debug('vue-i18n-locale-message:squeezer');
6-
function sqeeze(basePath, files) {
6+
function squeeze(basePath, files) {
77
const descriptors = utils_1.reflectSFCDescriptor(basePath, files);
88
return descriptors.reduce((meta, descriptor) => {
99
descriptor.customBlocks.sort((a, b) => { return a.start - b.start; });
@@ -13,7 +13,7 @@ function sqeeze(basePath, files) {
1313
return meta;
1414
}, { target: basePath, components: {} });
1515
}
16-
exports.default = sqeeze;
16+
exports.default = squeeze;
1717
function squeezeFromCustomBlocks(blocks) {
1818
return blocks.map(block => {
1919
if (block.type === 'i18n') {

lib/utils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ function reflectSFCDescriptor(basePath, components) {
4343
filename: target.path,
4444
compiler: compiler
4545
});
46-
return Object.assign({}, parsePath(basePath, target.path), { raw: target.content, customBlocks,
46+
return Object.assign(Object.assign({}, parsePath(basePath, target.path)), { raw: target.content, customBlocks,
4747
template,
4848
script,
4949
styles });
@@ -77,19 +77,19 @@ function parseContent(content, lang) {
7777
}
7878
}
7979
exports.parseContent = parseContent;
80-
function stringfyContent(content, lang) {
80+
function stringifyContent(content, lang) {
8181
switch (lang) {
8282
case 'yaml':
8383
case 'yml':
84-
return js_yaml_1.default.safeDump(content);
84+
return js_yaml_1.default.safeDump(content, { indent: 2 });
8585
case 'json5':
8686
return json5_1.default.stringify(content, null, 2);
8787
case 'json':
8888
default:
8989
return JSON.stringify(content, null, 2);
9090
}
9191
}
92-
exports.stringfyContent = stringfyContent;
92+
exports.stringifyContent = stringifyContent;
9393
function readSFC(target) {
9494
const targets = resolveGlob(target);
9595
debug('readSFC: targets = ', targets);

0 commit comments

Comments
 (0)