Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
requirejs-react-jsx
Advanced tools
A RequireJS plugin for compiling React JSX files. Will use react-tools when compiling using r.js
, and will use JSXTransformer
when running in the browser in development. This allows us to support multiple bundles in r.js
and exclude the JSXTransformer
from all of them since we're requiring it dynamically and not explicitly. This also means that we can get 1:1
Source Maps in both development and production.
$ bower install requirejs-react-jsx --save
If you're not using bower to manage your dependencies (you should), you can just download the jsx.js file manually.
Since we're also using react-tools for the build step while running in a node process, and not in the browser, you will need to install that also:
$ npm install react-tools --save
app.js
define(function(require){
var React = require('react');
function App() {
this.AppView = React.createClass({
render: function () {
return (
<div>
<p>Hello, React!</p>
</div>
);
}
});
}
App.prototype.init = function () {
React.render(<this.AppView />, document.body);
};
return App;
});
main.js
require.config({
paths: {
"react": "bower_components/react/react-with-addons",
"JSXTransformer": "bower_components/react/JSXTransformer",
"jsx": "bower_components/requirejs-react-jsx/jsx",
"text": "bower_components/requirejs-text/text"
},
shim : {
"react": {
"exports": "React"
},
"JSXTransformer": "JSXTransformer"
},
jsx: {
fileExtension: ".jsx",
transformOptions: {
harmony: true,
stripTypes: false,
inlineSourceMap: true
},
usePragma: false
}
});
require(['jsx!app'], function(App){
var app = new App();
app.init();
});
Call with $ node bower_components/r.js/dist/r.js -o build.js
In your r.js build.js
config:
// add `optimize=none` to skip script optimization (useful during debugging).
({
appDir: "./",
baseUrl: "./",
dir: "./compiled",
mainConfigFile: "./main.js",
optimize: "uglify2",
skipDirOptimize: true,
generateSourceMaps: true,
findNestedDependencies: true,
preserveLicenseComments: false,
onBuildWrite: function (moduleName, path, singleContents) {
return singleContents.replace(/jsx!/g, '');
},
modules: [
{
name: "main",
exclude: ['jsx']
}
]
})
FAQs
A RequireJS plugin for loading jsx in require.js and r.js
The npm package requirejs-react-jsx receives a total of 230 weekly downloads. As such, requirejs-react-jsx popularity was classified as not popular.
We found that requirejs-react-jsx demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.