Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doc: Typescript support #2066

Open
lifeart opened this issue Jul 10, 2023 · 0 comments
Open

Doc: Typescript support #2066

lifeart opened this issue Jul 10, 2023 · 0 comments

Comments

@lifeart
Copy link

lifeart commented Jul 10, 2023

Writing this issue to show how we could have typescript compilation support using babel.

function es6() {
  return browserify({
    entries: './src/js/main.js',
    extensions: ['.js', '.ts'],
  })
    .transform(
      babelify.configure({
        "presets": [
          "@babel/preset-env", 
          "module:@babel/preset-typescript"
        ],
        "plugins": ["@babel/proposal-class-properties"]
      }),
      { extensions: ['.js', '.ts'] },
    )
    .bundle()
    .pipe(source('main.js'))
}

In short, we have to add .ts extension to browserify config, and specify proper babel plugins (@babel/preset-typescript)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant