require-tsx
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

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.

/require-tsx/

    Package Sidebar

    Install

    npm i require-tsx

    Weekly Downloads

    0

    Version

    0.1.0

    License

    MIT

    Unpacked Size

    41.1 kB

    Total Files

    26

    Last publish

    Collaborators

    • boenfu