Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

require-tsx

boenfu14MIT0.1.0TypeScript support: included

direct require .tsx in Node.js

readme

require-tsx

direct require .tsx in Node.js

npm version Install Size MIT License

Usage

Installation:

yarn add require-tsx # Or npm install --save require-tsx
// require in main file
require('require-tsx');

Examples

Basic

  • index.js
require('require-tsx');
require('./foo').test();
  • foo.tsx
export function test() {
  return <div>Are you OK?</div>;
}

Custom Inject

require('require-tsx').inject({
  '.txt': (content, fileName) => content.replace('foo', 'bar'),
});

more see source code

Motivation

I want render React components to DOM string by direct require.

You should think carefully before using this repo in production. No usability and compatibility tests.

License

MIT License.