sintaxi / harp

Static Web Server/Generator/Bundler
http://harpjs.com
4.99k stars 346 forks source link

About esbuild config #667

Open aoisummer opened 3 years ago

aoisummer commented 3 years ago

Is there any options to config the target of esbuild? I want to compile code to es5 to be compatible with more browsers.

// ./src/assets/test.jsx

ReactDOM.render(
    <div>Hello world</div>,
    document.querySelector('#root')
);

// ./dist/assets/test.js

(() => { // <- Here is ES6 arrow function
  // assets/test.jsx
  ReactDOM.render(/* @__PURE__ */ React.createElement("div", null, "Hello world"), document.querySelector("#root"));
})();
sintaxi commented 3 years ago

Hmm, harp doesn't yet expose this yet but it makes sense to do so. Are you aware of how to configure esbuild?

aoisummer commented 3 years ago

Maybe I can understand the reason for doing that, but it's actually limit the browser support for this feature, by the way the follow code is an example:

require('esbuild').build({
    entryPoints: ['src/test.jsx'],
    bundle: true,
    outfile: 'dist/test.js',
    target: 'es5', // <- here
});
sintaxi commented 3 years ago

Thanks. I'll see what I can do.