Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typescript extractor linked to typescript-lingui-extract-messages #150

Closed
wants to merge 1 commit into from
Closed
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
1 change: 0 additions & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
},
"bootstrap": {
"ignore": [
"typescript-lingui-extract-messages"
]
}
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"watch:integration": "jest --watch examples/",
"watch": "jest --watch packages/ examples/",
"bootstrap": "lerna bootstrap --npm-client=yarn",
"clean": "lerna clean --npm-client=yarn",
"publish": "lerna publish --conventional-commits -m 'chore(release): publish [ci skip]' --registry=https://registry.npmjs.org/",
"lint:flow": "flow",
"lint:eslint": "eslint packages/",
Expand Down
38 changes: 30 additions & 8 deletions packages/lingui-cli/src/api/extractors/typescript.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
// @flow
import type { ExtractorType } from "./types"
"use strict";

const typescriptRe = /\.jsx?$/i
Object.defineProperty(exports, "__esModule", {
value: true
});

const extractor: ExtractorType = {
var _babelCore = require("babel-core");

var _babelPluginLinguiTransformReact = require("babel-plugin-lingui-transform-react");

var _babelPluginLinguiTransformReact2 = _interopRequireDefault(_babelPluginLinguiTransformReact);

var _typescriptLinguiExtractMessages = require("typescript-lingui-extract-messages");

var _typescriptLinguiExtractMessages2 = _interopRequireDefault(_typescriptLinguiExtractMessages);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

var typescriptRe = /\.tsx?$/i;

var extractor = {
match(filename) {
return typescriptRe.test(filename)
return typescriptRe.test(filename);
},

extract(filename, targetDir) {}
}
/*extract(filename, targetDir) {
console.log("typescript extract", filename);
}*/
extract(filename, localeDir) {
(0, _babelCore.transformFileSync)(filename, {
plugins: [_babelPluginLinguiTransformReact2.default, [_typescriptLinguiExtractMessages2.default, { localeDir }]]
});
}
};

export default extractor
exports.default = extractor;
5 changes: 5 additions & 0 deletions packages/typescript-lingui-extract-messages/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = {
plugins: [
require("./dist/index.js"),
]
}
2 changes: 1 addition & 1 deletion packages/typescript-lingui-extract-messages/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@
"typescript": "^2.4.2"
},
"scripts": {
"prepublish": "tsc --module system --outFile dist/index.js src/index.ts"
"prepublish": "tsc --module system --outFile dist/index.js src/index.ts --target es6 --moduleResolution node"
}
}