preact-compat icon indicating copy to clipboard operation
preact-compat copied to clipboard

fix for tsx annoyance

Open jeremy-coleman opened this issue 5 years ago • 1 comments

any better solution than this?lol

var gulp = require('gulp');
var replace = require('gulp-batch-replace');
var rename = require('gulp-rename')

let t1 = "= preact"
let t2 = "namespace preact"
let r1 = "= React"
let r2 = "namespace React"

var replacements = [
	[ t1, r1 ],
    [ t2, r2]
]

gulp.task('setup', () => {
        return gulp.src('node_modules/preact/src/preact.d.ts')
        .pipe(replace(replacements))
        .pipe(rename('index.d.ts'))
        .pipe(gulp.dest('node_modules/@types/react'))
});

jeremy-coleman avatar Dec 28 '18 23:12 jeremy-coleman

One more method can be to add aliases in your tsconfig.json

{
  "compilerOptions": {
    "paths": {
      "react": ["preact-compact"],
      "react-dom": ["preact-compact"]
    }
  }
}

You would have to alias the same in your build tools as well. (Webpack etc.)

azizhk avatar May 31 '19 12:05 azizhk