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

Use microbundle instead of Webpack #312

Merged
merged 10 commits into from
Sep 4, 2020
Merged

Use microbundle instead of Webpack #312

merged 10 commits into from
Sep 4, 2020

Conversation

bakerkretzmar
Copy link
Collaborator

@bakerkretzmar bakerkretzmar commented Aug 1, 2020

This PR replaces Webpack with microbundle, which uses Rollup under the hood. Microbundle is faster, the output is smaller, and there's way less to install and configure.

I also tweaked the outputs/targets:

  • route.js is the default (main, umd:main, unpkg, and browser), it's a UMD build that should work basically everywhere
  • route.m.js is an ES module (module)
  • route.es.js is an ES module specifically targeting modern browsers, so it's a bit smaller and faster than route.m.js
  • there's no CommonJS/Node buildroute.js should just work, bundlers or packages like esm can be used to import route.m.js if necessary, and Ziggy's target environment is the browser anyway

All tests pass on all of these builds, but I'll keep playing around with this in real apps and in the browser before it's merged.

See also Writing a small module in 2018

@bakerkretzmar bakerkretzmar added this to the v1.0 milestone Aug 1, 2020
@ankurk91
Copy link
Contributor

ankurk91 commented Aug 9, 2020

We can disable source maps with --sourcemap option.

@bakerkretzmar
Copy link
Collaborator Author

If someone doesn't want to use the default route.js build, they can specify which build they want to import in one of two ways:

Import a specific file:

import route from 'ziggy-js/dist/route.es.js';

Use a Webpack alias:

// in webpack.mix.js

mix.webpackConfig({
    resolve: {
        alias: {
            ziggy: 'ziggy-js/dist/route.es.js',
        },
    },
});
// in app.js or anywhere else

import ziggy from 'ziggy';

@bakerkretzmar bakerkretzmar merged commit 710b011 into develop Sep 4, 2020
@bakerkretzmar bakerkretzmar deleted the jbk/microbundle branch September 4, 2020 20:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants