@@ -48,9 +48,7 @@ export default (dir: string) => {
4848 for ( const locale in allTranslations ) {
4949 const currentTranslations = allTranslations [ locale ]
5050 for ( const [ usage , msgIds ] of Object . entries ( context ) ) {
51- if ( ! ( usage in translations ) ) {
52- translations [ usage ] = [ ]
53- }
51+ translations [ usage ] ??= [ ]
5452 // split the translations by usage in components
5553 translations [ usage ] . push ( {
5654 l : locale ,
@@ -78,8 +76,9 @@ export default (dir: string) => {
7876 return null
7977 } else if ( source . endsWith ( 'l10n.js' ) && importer && ! importer . includes ( 'node_modules' ) ) {
8078 if ( dirname ( resolve ( dirname ( importer ) , source ) ) . split ( '/' ) . at ( - 1 ) === 'src' ) {
79+ const [ path ] = importer . split ( '?' , 2 )
8180 // return our wrapper for handling the import
82- return `\0l10nwrapper?source=${ encodeURIComponent ( importer ) } `
81+ return `\0l10nwrapper?source=${ encodeURIComponent ( path ! ) } `
8382 }
8483 }
8584 } ,
@@ -105,7 +104,9 @@ export default (dir: string) => {
105104 return `import {t,n,register,${ imports . join ( ',' ) } } from '\0l10n';register(${ imports . join ( ',' ) } );export {t,n};`
106105 } else if ( id === '\0l10n' ) {
107106 // exports are all chunked translations
108- const exports = Object . entries ( nameMap ) . map ( ( [ usage , id ] ) => `export const ${ id } = ${ JSON . stringify ( translations [ usage ] ) } ` ) . join ( ';\n' )
107+ const exports = Object . entries ( nameMap )
108+ . map ( ( [ usage , id ] ) => `export const ${ id } = ${ JSON . stringify ( translations [ usage ] ) } ` )
109+ . join ( ';\n' )
109110 return `${ l10nRegistrationCode } \n${ exports } `
110111 }
111112 } ,
0 commit comments