retejs / rete-cli

Effortless plugin development with TypeScript, ESLint and Jest
https://retejs.org/docs/development/rete-cli
MIT License
4 stars 8 forks source link

[FR] please add a option to exclude polyfills for min version #2

Closed trsh closed 5 years ago

trsh commented 5 years ago
export default {
    input: 'src/index.js',
    name: 'xxx',
    globals: {
    },
    polyfills: false, // HERE!!!!!
    plugins: [
        sass({
            insert: true
        })
    ]
}
trsh commented 5 years ago

I actually think the coolest thing would be a 3rd build > like xx-xx-plugin.raw.min.js, that contains no polys!!! Coders than can choose to add or not them with external link :)).. depending on browser requirements.

Ni55aN commented 5 years ago

Minified bundle (especially transpiled from ES8 to olders versions) without polyfills can causing errors such as asyncIterator is not defined or similar. This is an extra complexity that gives more errors than good.

I think the best solution would be to add "module" property to package.json of each plugin.

"module": "build/some-plugin.debug.js",

This way when building your application using webpack it will import *.debug.js for import SomePlugin from 'rete-some-plugin'; *.debug.js does not have polyfills, since the source code is not converted to older versions. Converting to old versions is going with webpack (if you configure it)

Ni55aN commented 5 years ago

https://github.com/retejs/rete/issues/237

Ni55aN commented 5 years ago

Since v1.0.2 there is ES modules without polyfills (built by rete-cli@0.4.2).

*.esm.js hasn't polyfills and not minified. *.min.js has polyfills and minified.

*.esm.js may be minified during the build of your project. It allows to reduce a bandle by ~5kb due to the exclusion of polyfills.

Ni55aN commented 5 years ago

@trsh starting from rete-cli@0.5.0 (and rete@1.0.3) we have three formats of bundle:

trsh commented 5 years ago

@Ni55aN cool, tnx. Pretty busy lately with other stuff :/