0.1.0 • Published 2 years ago

require-tsx v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

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.