gatsby-plugin-typescript
Advanced tools
Comparing version
@@ -1,2 +0,2 @@ | ||
'use strict'; | ||
"use strict"; | ||
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { | ||
var _stringify = require('babel-runtime/core-js/json/stringify'); | ||
var _stringify = require("babel-runtime/core-js/json/stringify"); | ||
var _stringify2 = _interopRequireDefault(_stringify); | ||
var _assign = require('babel-runtime/core-js/object/assign'); | ||
var _assign = require("babel-runtime/core-js/object/assign"); | ||
@@ -20,3 +20,3 @@ var _assign2 = _interopRequireDefault(_assign); | ||
var _typescript = require('typescript'); | ||
var _typescript = require("typescript"); | ||
@@ -27,17 +27,19 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var compilerDefaults = { | ||
target: 'esnext', | ||
target: "esnext", | ||
experimentalDecorators: true, | ||
jsx: 'react' | ||
jsx: "react" | ||
}; | ||
function resolvableExtensions(ctx) { | ||
return ['.ts', '.tsx']; | ||
return [".ts", ".tsx"]; | ||
} | ||
function modifyWebpackConfig(ctx) { | ||
var config = ctx.args.config, | ||
compilerOptions = ctx.pluginOptions.compilerOptions; | ||
function modifyWebpackConfig(_ref, _ref2) { | ||
var config = _ref.config; | ||
var compilerOptions = _ref2.compilerOptions; | ||
// CommonJS to keep Webpack happy. | ||
var copts = (0, _assign2.default)(compilerDefaults, compilerOptions, { module: 'commonjs' }); | ||
var copts = (0, _assign2.default)(compilerDefaults, compilerOptions, { | ||
module: "commonjs" | ||
}); | ||
// React-land is rather undertyped; nontrivial TS projects will most likely | ||
@@ -48,15 +50,20 @@ // error (i.e., not build) at something or other. | ||
// in the project directory. | ||
config.loader('typescript', { test, loader: 'ts-loader?' + (0, _stringify2.default)(opts) }); | ||
config.loader("typescript", { | ||
test, | ||
loader: "ts-loader?" + (0, _stringify2.default)(opts) | ||
}); | ||
} | ||
function preprocessSource(ctx) { | ||
var _ctx$args = ctx.args, | ||
contents = _ctx$args.contents, | ||
filename = _ctx$args.filename, | ||
compilerOptions = ctx.pluginOptions.compilerOptions; | ||
function preprocessSource(_ref3, _ref4) { | ||
var contents = _ref3.contents, | ||
filename = _ref3.filename; | ||
var compilerOptions = _ref4.compilerOptions; | ||
// overwrite defaults with custom compiler options | ||
var copts = (0, _assign2.default)(compilerDefaults, compilerOptions, { target: 'esnext', module: 'es6' }); | ||
var copts = (0, _assign2.default)(compilerDefaults, compilerOptions, { | ||
target: "esnext", | ||
module: "es6" | ||
}); | ||
// return the transpiled source if it's TypeScript, otherwise null | ||
return test.test(filename) ? (0, _typescript.transpileModule)(contents, { compilerOptions: copts }).outputText : null; | ||
} |
{ | ||
"name": "gatsby-plugin-typescript", | ||
"version": "1.0.0-alpha12-alpha.4f30010e", | ||
"version": "1.0.0-alpha12-alpha.51e1923f", | ||
"description": "Adds TypeScript support for Gatsby layouts and pages.", | ||
@@ -5,0 +5,0 @@ "author": "Kyle Mathews <mathews.kyle@gmail.com>", |
62
12.73%3998
-0.52%