Security News
JavaScript Leaders Demand Oracle Release the JavaScript Trademark
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
ts-jsx-loader
Advanced tools
Webpack loader for transforming JSX based on special syntax. Meant to be used with a TypeScript loader to allow using JSX with TypeScript.
npm install ts-jsx-loader
The loader chain should go from ts-jsx-loader into a TypeScript loader. Your configuration will look something like this:
module.exports = {
entry: './app.ts',
output: {
filename: 'bundle.js'
},
resolve: {
extensions: ['', '.webpack.js', '.web.js', '.js', '.ts']
},
module: {
loaders: [
{ test: /\.ts$/, loader: 'ts-loader!ts-jsx-loader' }
]
}
}
ts-jsx-loader defines a fake API on React called React.jsx(). You should
reference the included react-jsx.d.ts
or react-addons-jsx.d.ts
definition file for IDE support. This API accepts either a string or nothing.
You can then create JSX as a template string or within multiline comments.
///<reference path="path/to/react-jsx.d.ts"/>
import React = require('react');
var message = 'Hello world'
React.render(React.jsx(/*
<div>
<span>{message}</span>
</div>
*/), document.body)
// or if you're using TypeScript 1.4 or above with template strings, with or without embedded expressions
React.render(React.jsx(`
<div>
<span>${message}</span>
</div>
`), document.body)
React.render(React.jsx(`
<div>
<span>{message}</span>
</div>
`), document.body)
// or if you simply want to use JSX without making it valid TypeScript
React.render(
/*jsx*/
<div>
<span>{message}</span>
</div>
/*jsx*/
, document.body)
The loader will find occurrences of React.jsx()
or /*jsx*/
and transform them into
React.createElement() calls prior to being passed to the TypeScript
loader.
Specify options to the loader via query string:
...
module: {
loaders: [
{ test: /\.ts$/, loader: 'ts-loader!ts-jsx-loader?target=es3&identifier=react.jsx' }
]
}
...
Allows the use of ES6 features within JSX.
Change the identifier to something other than React.jsx
. For example, you
could import React with a lower-case r like so:
import react = require('react')
react.jsx(`<div />`)
Specify the output target. See this for more information.
The MIT License (MIT)
Copyright (c) 2015 James Brantly
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
v0.2.1
FAQs
Webpack loader for transforming JSX in TypeScript files.
The npm package ts-jsx-loader receives a total of 7 weekly downloads. As such, ts-jsx-loader popularity was classified as not popular.
We found that ts-jsx-loader demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In an open letter, JavaScript community leaders urge Oracle to give up the JavaScript trademark, arguing that it has been effectively abandoned through nonuse.
Security News
The initial version of the Socket Python SDK is now on PyPI, enabling developers to more easily interact with the Socket REST API in Python projects.
Security News
Floating dependency ranges in npm can introduce instability and security risks into your project by allowing unverified or incompatible versions to be installed automatically, leading to unpredictable behavior and potential conflicts.