We are trying to move to reactjs but a complete switch to javascript or jsx is not possible at the moment.
I tried a lot of those jsx packages but none of them really work. I managed it to build my own really working package but now have problems with getting rid of dependencies:
import CoffeeCompiler from 'meteor/coffeescript'; # just imports an empty object
import cjsx from 'coffee-react-transform';
export class CoffeeXCompiler extends CoffeeCompiler {
constructor() {
super();
}
_getCompileOptions(inputFile) {
return {
bare: true,
filename: inputFile.getPathInPackage(),
literate: inputFile.getExtension() !== 'cjsx',
// Return a source map.
sourceMap: true,
// This becomes the "file" field of the source map.
generatedFile: '/' + this._outputFilePath(inputFile),
// This becomes the "sources" field of the source map.
sourceFiles: [inputFile.getDisplayPath()],
};
}
compileOneFile(inputFile) {
const source = cjsx(inputFile.getContentsAsString());
inputFile._resourceSlot.inputResource.data = source;
return(super.compileOneFile(inputFile))
}
}
Plugin.registerCompiler({
extensions: ['cjsx', 'coffeex']
}, () => new CoffeeXCompiler());
when I copy&pasted the CoffeeCompiler code directly before my code, everything works fine, but I cannot import the CoffeeCompiler class from the meteor coffeescript package. it just imports an empty object. Even if it says export class CoffeeCompiler
in the coffeescript package.
How can i get rid of copy and pasting the coffeescript package in my package and how can I import this class from the package?