Skip to content

ref(build): Handle minification in rollup config generation function #4681

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 7 commits into from
Mar 7, 2022

Conversation

lobsterkatie
Copy link
Member

@lobsterkatie lobsterkatie commented Mar 3, 2022

As part of the new build process, this removes minification config from being hardcoded in individual rollup.config.js files and instead uses a new function in the main rollup.config.js to generate minified and unminified variants of each build config it's given.

This PR also includes a few other small changes:

  • Moved the license plugin to the main config function.
  • Removed exports which were no longer necessary now that most config is centralized.
  • Refactored individual rollup.config.js files to have more parallel structure.
  • Moved a comment and renamed the markAsBrowserBulid plugin so it has the work "plugin" in its name.

Ref: https://getsentry.atlassian.net/browse/WEB-633

@github-actions
Copy link
Contributor

github-actions bot commented Mar 3, 2022

size-limit report

Path Base Size (61c79ef) Current Size Change
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.79 KB 19.79 KB -0.01% 🔽
@sentry/browser - ES5 CDN Bundle (minified) 63.38 KB 63.38 KB 0%
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.44 KB 18.44 KB -0.02% 🔽
@sentry/browser - ES6 CDN Bundle (minified) 56.41 KB 56.41 KB 0%
@sentry/browser - Webpack (gzipped + minified) 22.27 KB 22.27 KB 0%
@sentry/browser - Webpack (minified) 76.34 KB 76.34 KB 0%
@sentry/react - Webpack (gzipped + minified) 22.3 KB 22.3 KB 0%
@sentry/nextjs Client - Webpack (gzipped + minified) 46.43 KB 46.43 KB 0%
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.69 KB 26.68 KB -0.01% 🔽
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.01 KB 25.01 KB -0.02% 🔽

@lobsterkatie lobsterkatie force-pushed the kmclb-handle-minification-in-rollup-function branch from 6f5727e to 261d1e8 Compare March 4, 2022 16:50
@lobsterkatie lobsterkatie marked this pull request as ready for review March 4, 2022 18:27
@lobsterkatie lobsterkatie requested a review from AbhiPrasad March 4, 2022 18:27
rollup.config.js Outdated
Comment on lines 22 to 23
}
export function insertAt(arr, index, insertee) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't prettier?

Suggested change
}
export function insertAt(arr, index, insertee) {
}
export function insertAt(arr, index, insertee) {

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean, does prettier get mad that there's not a blank line there? No - it would have failed linting. My thinking in not putting a blank there is I wanted the comment to apply to both, and it felt like they were both small enough I could get away with it. But you're not wrong, it's a little weird looking. Compromise option:

/**
 * Helper functions to compensate for the fact that JS can't handle negative array indices very well
 *
 * TODO `insertAt` is only exported so the integrations config can inject the `commonjs` plugin, for localforage (used
 * in the offline plugin). Once that's fixed to no longer be necessary, this can stop being exported.
 */
const getLastElement = array => {
  return array[array.length - 1];
};
export const insertAt = (arr, index, insertee) => {
  const newArr = [...arr];
  // Add 1 to the array length so that the inserted element ends up in the right spot with respect to the length of the
  // new array (which will be one element longer), rather than that of the current array
  const destinationIndex = index >= 0 ? index : arr.length + 1 + index;
  newArr.splice(destinationIndex, 0, insertee);
  return newArr;
};

Functionally* the same, but having two consts in a row is better. I'll switch it to that.

* no pun intended, I swear

@lobsterkatie lobsterkatie force-pushed the kmclb-handle-minification-in-rollup-function branch from 261d1e8 to f8b436e Compare March 4, 2022 21:13
@lobsterkatie lobsterkatie force-pushed the kmclb-handle-minification-in-rollup-function branch from f8b436e to 6b30492 Compare March 7, 2022 14:54
@lobsterkatie lobsterkatie enabled auto-merge (squash) March 7, 2022 14:54
@lobsterkatie lobsterkatie merged commit a1e97ea into master Mar 7, 2022
@lobsterkatie lobsterkatie deleted the kmclb-handle-minification-in-rollup-function branch March 7, 2022 15:08
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