@intlify/bundle-utils
Advanced tools
Comparing version 3.1.0 to 3.1.1
@@ -1,2 +0,2 @@ | ||
import { ResourceNode } from '@intlify/message-compiler'; | ||
import { CompileError, ResourceNode } from '@intlify/message-compiler'; | ||
import { SourceMapGenerator } from 'source-map'; | ||
@@ -38,3 +38,8 @@ import type { RawSourceMap } from 'source-map'; | ||
onWarn?: (msg: string) => void; | ||
onError?: (msg: string) => void; | ||
onError?: (msg: string, extra?: { | ||
source: string; | ||
code?: CompileError['code']; | ||
domain?: CompileError['domain']; | ||
location?: CompileError['location']; | ||
}) => void; | ||
} | ||
@@ -41,0 +46,0 @@ export interface CodeGenContext { |
@@ -99,9 +99,19 @@ "use strict"; | ||
const env = options.env != null ? options.env : 'development'; | ||
let occured = false; | ||
const newOptions = Object.assign(options, { mode: 'arrow' }); | ||
const onError = options.onError; | ||
const errors = []; | ||
const newOptions = Object.assign({ mode: 'arrow' }, options); | ||
newOptions.onError = (err) => { | ||
options.onError && options.onError(err.message); | ||
occured = true; | ||
if (onError) { | ||
const extra = { | ||
source: msg, | ||
code: err.code, | ||
domain: err.domain, | ||
location: err.location | ||
}; | ||
onError(err.message, extra); | ||
errors.push(err); | ||
} | ||
}; | ||
const { code, ast, map } = (0, message_compiler_1.baseCompile)(msg, newOptions); | ||
const occured = errors.length > 0; | ||
const genCode = !occured | ||
@@ -108,0 +118,0 @@ ? env === 'development' |
@@ -10,2 +10,2 @@ /** | ||
*/ | ||
export declare function generate(targetSource: string | Buffer, { type, bridge, exportESM, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, useClassComponent }: CodeGenOptions, injector?: () => string): CodeGenResult<JSONProgram>; | ||
export declare function generate(targetSource: string | Buffer, { type, bridge, exportESM, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError, useClassComponent }: CodeGenOptions, injector?: () => string): CodeGenResult<JSONProgram>; |
@@ -13,3 +13,3 @@ "use strict"; | ||
*/ | ||
function generate(targetSource, { type = 'plain', bridge = false, exportESM = false, filename = 'vue-i18n-loader.json', inSourceMap = undefined, locale = '', isGlobal = false, sourceMap = false, env = 'development', forceStringify = false, useClassComponent = false }, injector) { | ||
function generate(targetSource, { type = 'plain', bridge = false, exportESM = false, filename = 'vue-i18n-loader.json', inSourceMap = undefined, locale = '', isGlobal = false, sourceMap = false, env = 'development', forceStringify = false, onError = undefined, useClassComponent = false }, injector) { | ||
const target = Buffer.isBuffer(targetSource) | ||
@@ -34,2 +34,3 @@ ? targetSource.toString() | ||
forceStringify, | ||
onError, | ||
useClassComponent | ||
@@ -36,0 +37,0 @@ }; |
@@ -10,2 +10,2 @@ /** | ||
*/ | ||
export declare function generate(targetSource: string | Buffer, { type, bridge, exportESM, useClassComponent, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify }: CodeGenOptions, injector?: () => string): CodeGenResult<YAMLProgram>; | ||
export declare function generate(targetSource: string | Buffer, { type, bridge, exportESM, useClassComponent, filename, inSourceMap, locale, isGlobal, sourceMap, env, forceStringify, onError }: CodeGenOptions, injector?: () => string): CodeGenResult<YAMLProgram>; |
@@ -13,3 +13,3 @@ "use strict"; | ||
*/ | ||
function generate(targetSource, { type = 'plain', bridge = false, exportESM = false, useClassComponent = false, filename = 'vue-i18n-loader.yaml', inSourceMap = undefined, locale = '', isGlobal = false, sourceMap = false, env = 'development', forceStringify = false }, injector) { | ||
function generate(targetSource, { type = 'plain', bridge = false, exportESM = false, useClassComponent = false, filename = 'vue-i18n-loader.yaml', inSourceMap = undefined, locale = '', isGlobal = false, sourceMap = false, env = 'development', forceStringify = false, onError = undefined }, injector) { | ||
const value = Buffer.isBuffer(targetSource) | ||
@@ -30,2 +30,3 @@ ? targetSource.toString() | ||
forceStringify, | ||
onError, | ||
useClassComponent | ||
@@ -32,0 +33,0 @@ }; |
{ | ||
"name": "@intlify/bundle-utils", | ||
"description": "Bundle utilities for Intlify project", | ||
"version": "3.1.0", | ||
"version": "3.1.1", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "kazuya kawaguchi", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
15
810
36460