Skip to content

Use iife format for Rollup #141

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

Merged
merged 1 commit into from
Jun 18, 2023
Merged

Use iife format for Rollup #141

merged 1 commit into from
Jun 18, 2023

Conversation

ankane
Copy link
Contributor

@ankane ankane commented Jan 7, 2023

Currently, both esbuild and Webpack output a self-executing function.

(() => {
  // code
})();

This PR updates Rollup to do the same.

(function () {
  // code
})();

With the current es format, Rollup can set a lot of variables and functions on the window object. You can see this with the chart.js package and the following application.js:

import { Chart } from "chart.js/auto"

window.Chart = Chart

With esbuild and Webpack, this only sets an additional Chart variable on window. With Rollup, it sets 400+ more properties.

Object.keys(window).length

@dhh dhh merged commit a7080a5 into rails:main Jun 18, 2023
@ankane
Copy link
Contributor Author

ankane commented Jun 19, 2023

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants