import-jsx

WebJar for import-jsx

License

License

MIT
Categories

Categories

Github Development Tools Version Controls
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

github-com-isaacs-import-jsx
Last Version

Last Version

1.3.0
Release Date

Release Date

Type

Type

jar
Description

Description

import-jsx
WebJar for import-jsx
Project URL

Project URL

http://webjars.org
Source Code Management

Source Code Management

https://github.com/isaacs/import-jsx

Download github-com-isaacs-import-jsx

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/github-com-isaacs-import-jsx/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>github-com-isaacs-import-jsx</artifactId>
    <version>1.3.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/github-com-isaacs-import-jsx/
implementation 'org.webjars.npm:github-com-isaacs-import-jsx:1.3.0'
// https://jarcasting.com/artifacts/org.webjars.npm/github-com-isaacs-import-jsx/
implementation ("org.webjars.npm:github-com-isaacs-import-jsx:1.3.0")
'org.webjars.npm:github-com-isaacs-import-jsx:jar:1.3.0'
<dependency org="org.webjars.npm" name="github-com-isaacs-import-jsx" rev="1.3.0">
  <artifact name="github-com-isaacs-import-jsx" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='github-com-isaacs-import-jsx', version='1.3.0')
)
libraryDependencies += "org.webjars.npm" % "github-com-isaacs-import-jsx" % "1.3.0"
[org.webjars.npm/github-com-isaacs-import-jsx "1.3.0"]

Dependencies

compile (7)

Group / Artifact Type Version
org.webjars.npm : resolve-from jar [3.0.0,4)
org.webjars.npm : require-from-string jar [1.2.1,2)
org.webjars.npm : babel-core jar [6.25.0,7)
org.webjars.npm : babel-plugin-transform-object-rest-spread jar [6.23.0,7)
org.webjars.npm : babel-plugin-transform-es2015-destructuring jar [6.23.0,7)
org.webjars.npm : caller-path jar [2.0.0,3)
org.webjars.npm : babel-plugin-transform-react-jsx jar [6.24.1,7)

Project Modules

There are no modules declared in this project.

import-jsx Build Status

Require and transpile JSX on the fly

  • Doesn't install any require() hooks
  • Auto-detects React pragma (React.createElement) and falls back to h pragma supported by Preact and others
  • Caches transpiled sources by default
  • Bundles in object rest spread transform

Install

$ npm install --save import-jsx

Usage

const importJsx = require('import-jsx');

const reactComponent = importJsx('./react');
const preactComponent = importJsx('./preact');
const customComponent = importJsx('./custom', {pragma: 'x'});

react.js

const React = require('react');

module.exports = <div/>;

preact.js

const {h} = require('preact');

module.exports = <div/>;

custom.js

const x = (tagName, attrs, ...children) => {};

module.exports = <div/>;

API

importJsx(moduleId, [options])

moduleId

Type: string

Module id.

options

pragma

Type: string
Default: h

Override JSX pragma.

cache

Type: boolean
Default: true

Enable or disable caching of transpiled sources.

importJsx.create([options])

Factory method to create a version of importJsx() with pre-defined options. Useful when you need a custom pragma, but don't want to pass it along with each importJsx() call.

options

Type: object

Options to pass to importJsx().

// Before
const importJsx = require('import-jsx');

importJsx('./a', {pragma: 'x'});
importJsx('./b', {pragma: 'x'});

// After
const importJsx = require('import-jsx').create({pragma: 'x'});

importJsx('./a');
importJsx('./b');

License

MIT © Vadim Demedes

Versions

Version
1.3.0