|
@@ -1,7 +1,11 @@
|
|
|
|
|
+const fs = require('node:fs')
|
|
|
|
|
+const path = require('node:path')
|
|
|
|
|
+const typescript = require('typescript')
|
|
|
|
|
+
|
|
|
module.exports = {
|
|
module.exports = {
|
|
|
input: [
|
|
input: [
|
|
|
- 'frontend/js/**/*.{js,jsx}',
|
|
|
|
|
- 'modules/**/*.{js,jsx}',
|
|
|
|
|
|
|
+ 'frontend/js/**/*.{js,jsx,ts,tsx}',
|
|
|
|
|
+ 'modules/**/*.{js,jsx,ts,tsx}',
|
|
|
'!frontend/js/vendor/**',
|
|
'!frontend/js/vendor/**',
|
|
|
],
|
|
],
|
|
|
output: './',
|
|
output: './',
|
|
@@ -24,4 +28,22 @@ module.exports = {
|
|
|
lineEnding: '\n',
|
|
lineEnding: '\n',
|
|
|
},
|
|
},
|
|
|
},
|
|
},
|
|
|
|
|
+ // adapted from https://github.com/nucleartux/i18next-scanner-typescript/blob/master/src/index.js
|
|
|
|
|
+ transform: function (file, enc, done) {
|
|
|
|
|
+ const { base, ext } = path.parse(file.path)
|
|
|
|
|
+
|
|
|
|
|
+ if (['.ts', '.tsx'].includes(ext) && !base.endsWith('.d.ts')) {
|
|
|
|
|
+ const content = fs.readFileSync(file.path, enc)
|
|
|
|
|
+
|
|
|
|
|
+ const { outputText } = typescript.transpileModule(content, {
|
|
|
|
|
+ compilerOptions: { target: 'es2018', jsx: 'preserve' },
|
|
|
|
|
+ fileName: base,
|
|
|
|
|
+ })
|
|
|
|
|
+
|
|
|
|
|
+ this.parser.parseTransFromString(outputText)
|
|
|
|
|
+ this.parser.parseFuncFromString(outputText)
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ done()
|
|
|
|
|
+ },
|
|
|
}
|
|
}
|