floatdrop / plugin-jsx

JSX loader plugin
MIT License
36 stars 10 forks source link

Use jsx-transform #11

Open OliverJAsh opened 9 years ago

OliverJAsh commented 9 years ago

Could we use jsx-transform for users who are using JSX with non-React virtual DOM implementations?

https://github.com/alexmingoia/jsx-transform

floatdrop commented 9 years ago

I don't see, how you can use it - there is no way to pass different factory to jsx-transform, so without it will it be useless?

OliverJAsh commented 9 years ago

Like this?

var jsx = require('jsx-transform');

jsx.fromString('<h1>Hello World</h1>', {
  factory: 'mercury.h'
});
// => 'mercury.h("h1", null, ["Hello World"])'
floatdrop commented 9 years ago

@OliverJAsh yeah, but in client code it will be more like this:

var component = require('component.jsx');

And in component.jsx you have only one choise:

var React = require('react');
export <h1></h1>;

Afaik there is no way to configure jspm plugin atm.

OliverJAsh commented 9 years ago

@guybedford Is there any way to provide configuration options to a plugin, or could there be?

guybedford commented 9 years ago

Yes - meta configuration can do this:

System.config({
  meta: {
    'some/file.js': {
      loader: 'jsx',
      customOption: 'asdf'
    }
  }
});
OliverJAsh commented 9 years ago

Sorry for asking silly questions, but how would you read that custom option from within the plugin?

guybedford commented 9 years ago

metadata is passed as a property on the load object in the hooks.