Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions cli/src/lib/compiler/extensionHelpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
const extensionPattern = /\.[jt]sx?$/
const normalizeExtension = (ext) => ext.replace(extensionPattern, '.js')
const extensionPattern = /\.([jt])sx?$/
Copy link
Contributor Author

@KaiVandivier KaiVandivier Jun 16, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This regex is also used in the src/lib/compiler/compile.js file; I made sure this small change doesn't affect its usage there

const normalizeExtension = (path) => {
const match = path.match(extensionPattern)
if (match[1] === 't') {
// This is a .ts or .tsx file - convert to .js,
// since imports should omit extensions in TS files
return path.replace(extensionPattern, '.js')
}

// For .js or .jsx files, leave as-is
// (though actual JSX will still get transpiled by babel)
return path
}

module.exports.extensionPattern = extensionPattern
module.exports.normalizeExtension = normalizeExtension
11 changes: 11 additions & 0 deletions cli/src/lib/compiler/extensionHelpers.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { normalizeExtension } = require('./extensionHelpers.js')

test('it converts filenames with .ts or .tsx extensions to .js extensions', () => {
expect(normalizeExtension('filename.ts')).toBe('filename.js')
expect(normalizeExtension('filename.tsx')).toBe('filename.js')
})

test('it leaves filenames with .js or .jsx extensions as-is', () => {
expect(normalizeExtension('filename.js')).toBe('filename.js')
expect(normalizeExtension('filename.jsx')).toBe('filename.jsx')
})
16 changes: 12 additions & 4 deletions examples/simple-app/i18n/en.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@ msgstr ""
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
"POT-Creation-Date: 2019-10-02T21:55:28.107Z\n"
"PO-Revision-Date: 2019-10-02T21:55:28.107Z\n"
"POT-Creation-Date: 2025-06-16T09:46:24.381Z\n"
"PO-Revision-Date: 2025-06-16T09:46:24.381Z\n"

msgid "Hello {{name}}"
msgstr ""
msgstr "Hello {{name}}"

msgid "Have a great {{dayOfTheWeek}}!"
msgstr ""
msgstr "Have a great {{dayOfTheWeek}}!"

msgctxt "Application title"
msgid "__MANIFEST_APP_TITLE"
msgstr "Simple Example App"

msgctxt "Application description"
msgid "__MANIFEST_APP_DESCRIPTION"
msgstr "This is a simple example application"
Loading