i18next-scanner-typescript
Advanced tools
Comparing version 1.0.2 to 1.0.3
'use strict'; | ||
var fs = require("fs"); | ||
const fs = require("fs"); | ||
var path = require("path"); | ||
const path = require("path"); | ||
var typescript = require("typescript"); | ||
const typescript = require("typescript"); | ||
module.exports = function typescriptTransform(options) { | ||
options = options || {}; | ||
module.exports = function typescriptTransform(options = {}) { | ||
if (!options.extensions) { | ||
options.extensions = [".tsx"]; | ||
options.extensions = [".ts", ".tsx"]; | ||
} | ||
return function transform(file, enc, done) { | ||
const extension = path.extname(file.path); | ||
const parser = this.parser; | ||
let content = fs.readFileSync(file.path, enc); | ||
const { | ||
base, | ||
ext | ||
} = path.parse(file.path); | ||
if (options.extensions.indexOf(extension) !== -1) { | ||
content = typescript.transpileModule(content, { | ||
if (options.extensions.includes(ext) && !base.includes('.d.ts')) { | ||
const content = fs.readFileSync(file.path, enc); | ||
const { | ||
outputText | ||
} = typescript.transpileModule(content, { | ||
compilerOptions: { | ||
@@ -27,5 +29,5 @@ target: 'es2018' | ||
fileName: path.basename(file.path) | ||
}).outputText; | ||
parser.parseTransFromString(content); | ||
parser.parseFuncFromString(content); | ||
}); | ||
this.parser.parseTransFromString(outputText); | ||
this.parser.parseFuncFromString(outputText); | ||
} | ||
@@ -32,0 +34,0 @@ |
@@ -1,21 +0,23 @@ | ||
var fs = require("fs"); | ||
const fs = require("fs"); | ||
var path = require("path"); | ||
const path = require("path"); | ||
var typescript = require("typescript"); | ||
const typescript = require("typescript"); | ||
module.exports = function typescriptTransform(options) { | ||
options = options || {}; | ||
module.exports = function typescriptTransform(options = {}) { | ||
if (!options.extensions) { | ||
options.extensions = [".tsx"]; | ||
options.extensions = [".ts", ".tsx"]; | ||
} | ||
return function transform(file, enc, done) { | ||
const extension = path.extname(file.path); | ||
const parser = this.parser; | ||
let content = fs.readFileSync(file.path, enc); | ||
const { | ||
base, | ||
ext | ||
} = path.parse(file.path); | ||
if (options.extensions.indexOf(extension) !== -1) { | ||
content = typescript.transpileModule(content, { | ||
if (options.extensions.includes(ext) && !base.includes('.d.ts')) { | ||
const content = fs.readFileSync(file.path, enc); | ||
const { | ||
outputText | ||
} = typescript.transpileModule(content, { | ||
compilerOptions: { | ||
@@ -25,5 +27,5 @@ target: 'es2018' | ||
fileName: path.basename(file.path) | ||
}).outputText; | ||
parser.parseTransFromString(content); | ||
parser.parseFuncFromString(content); | ||
}); | ||
this.parser.parseTransFromString(outputText); | ||
this.parser.parseFuncFromString(outputText); | ||
} | ||
@@ -30,0 +32,0 @@ |
{ | ||
"name": "i18next-scanner-typescript", | ||
"description": "i18next-scanner Typescript transform", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"license": "MIT", | ||
"files": [ | ||
"dist-*/", | ||
"bin/" | ||
], | ||
"esnext": "dist-src/index.js", | ||
@@ -10,7 +14,2 @@ "main": "dist-node/index.js", | ||
"sideEffects": false, | ||
"files": [ | ||
"dist-*/", | ||
"assets/", | ||
"bin/" | ||
], | ||
"repository": { | ||
@@ -24,4 +23,4 @@ "type": "git", | ||
"devDependencies": { | ||
"@pika/plugin-build-node": "^0.3.11", | ||
"@pika/plugin-standard-pkg": "^0.3.11" | ||
"@pika/plugin-build-node": "^0.4.0", | ||
"@pika/plugin-standard-pkg": "^0.4.0" | ||
}, | ||
@@ -28,0 +27,0 @@ "private": false, |
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
2699
56