Skip to content

ref(build): Rename pack npm scripts to build:npm #4715

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

Conversation

Lms24
Copy link
Member

@Lms24 Lms24 commented Mar 14, 2022

This PR renames the pack npm scripts in all package.jsons to build:npm. Previously, these pack scripts could cause confusion in connection with yarn, as yarn pack and yarn run pack would do different things: While running the former would trigger the pack command of yarn (as in npm pack), the latter would execute whatever is defined in the resp. package.json under pack.
Up to recently, this difference was not noticeable in most SDKs because the pack npm script would simply be npm pack. However, given that we're moving everything build-related into its own build directory (#4688, #4641), the pack script must point to the package.json inside build. As a consequence, yarn run pack and yarn pack will behave differently which can cause confusion when creating a tarball.

With this PR, yarn (run) build:npm will create an NPM package (tarball). Besides modifying all SDK package.jsons, this PR also adjusts the packing script in the root-level package.json and hence in the the packaging command in the build.yml file.

It should be noted that the purpose of this PR is to avoid confusion when creating NPM packages, not to fix anything that would otherwise be "broken". CI also works currently with the build directory change as the artifact creation job does not call yarn pack but yarn pack:changed.
The motivation for making this change emerged after a conversation about adjusting yarn pack to yarn run pack to get a correct tarball.

ref: https://getsentry.atlassian.net/browse/WEB-688

@github-actions
Copy link
Contributor

github-actions bot commented Mar 14, 2022

size-limit report

Path Base Size (2d26879) Current Size Change
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.49 KB 19.49 KB 0%
@sentry/browser - ES5 CDN Bundle (minified) 62.17 KB 62.17 KB 0%
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.12 KB 18.12 KB +0.02% 🔺
@sentry/browser - ES6 CDN Bundle (minified) 55.5 KB 55.5 KB 0%
@sentry/browser - Webpack (gzipped + minified) 22.6 KB 22.6 KB 0%
@sentry/browser - Webpack (minified) 79.21 KB 79.21 KB 0%
@sentry/react - Webpack (gzipped + minified) 22.63 KB 22.63 KB 0%
@sentry/nextjs Client - Webpack (gzipped + minified) 47.6 KB 47.6 KB 0%
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 25.37 KB 25.37 KB +0.01% 🔺
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 23.72 KB 23.72 KB 0%

"pack": "npm pack",
"package": "run-s prepack && npm pack && run-s postpack",
Copy link
Member Author

@Lms24 Lms24 Mar 14, 2022

Choose a reason for hiding this comment

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

Looking at this, it probably makes more sense to inline the pre/postpack scripts under package instead of having three scripts here... is there anything I'm missing that would break if I did this?

Copy link
Member

Choose a reason for hiding this comment

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

Nope, don't think so. Good idea.

@Lms24 Lms24 changed the title ref(build): Rename pack npm scripts to package ref(build): Rename pack npm scripts to createTarball Mar 14, 2022
@Lms24 Lms24 marked this pull request as ready for review March 14, 2022 17:00
Copy link
Member

@lobsterkatie lobsterkatie left a comment

Choose a reason for hiding this comment

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

This looks good, and you explained it well!

One small suggestion (and yes, I know this is different than my off-the-cuff suggestion this morning - sorry! Reading it now I'm thinking about it more.): Without context, it might not be clear to all readers that "tarball" === "publishable npm package". Would you be good with yarn build:npm?

@Lms24
Copy link
Member Author

Lms24 commented Mar 17, 2022

Would you be good with yarn build:npm?

Generally yes. It's clear, short and captures what the script is doing. My only concern is that building for me entails some sort of compilation/transpilation going on whereas what yarn pack "only" takes (built) files + some assets and puts them into a tarball. I was already thinking about build:tarball before making the change to ceateTarball but decided against it due to this concern.

This might be just me though, so I'm happy to change it to build:npm.

EDIT: went with build:npm anyway, as it seems to be the best option

@Lms24 Lms24 changed the title ref(build): Rename pack npm scripts to createTarball ref(build): Rename pack npm scripts to build:npm Mar 17, 2022
@lobsterkatie
Copy link
Member

My only concern is that building for me entails some sort of compilation/transpilation going on whereas what yarn pack "only" takes (built) files + some assets and puts them into a tarball.

I hear what you're saying, but I think that's focusing too much on implementation details. For me, it all falls under the general heading of "putting stuff together so we can publish it." Looked at in that light, build:bundle makes the files we upload to our CDN, and build:npm will now make the files we upload to npm.

@Lms24 Lms24 force-pushed the lms-rename-pack branch from 0a1bef6 to 170fc6f Compare March 18, 2022 08:59
Lms24 added 6 commits March 22, 2022 09:46
rename `pack` npm scripts in all `package.json`s to `package`. Previously, these `pack`
scripts could cause confusion in connection with yarn, as `yarn pack` and `yarn run pack`
would do different things: While running the former would trigger the pack command of yarn
(as in `npm pack`), the latter would execute whatever is defined in the resp. `package.json`
undder `pack`.
Up to recently, this difference was not noticable in most SDKs because the `pack` npm script
would simply be `npm pack`. However given that we're moving everything build-related into
its own `build` directory, the pack script must point to the `package.json` inside `build`.
As a consequence, `yarn run pack` and `yarn pack` will behave differently which can cause
confusion when creating a tarball.
@Lms24 Lms24 force-pushed the lms-rename-pack branch from 170fc6f to e18a5e6 Compare March 22, 2022 08:47
@Lms24 Lms24 merged commit 29d5a16 into master Mar 22, 2022
@Lms24 Lms24 deleted the lms-rename-pack branch March 22, 2022 09:21
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.

3 participants