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

Fix issue where tsx would copy the package.json file where it shouldn't #1466

Merged
merged 4 commits into from
May 14, 2019

Conversation

amrocha
Copy link
Contributor

@amrocha amrocha commented May 14, 2019

WHY are these changes introduced?

We can't update polaris-react in web because of this bug.

This issue was introduced when we updated Typescript from 3.1.6 to 3.2.4.

WHAT is this pull request doing?

In 3.2.4, tsc includes the root directory's package.json file in the output build by default
This is a problem because the "files" key in the root package.json ends up filtering which files get included in the build output. Ideally the package.json file wouldn't be copied, but I couldn't easily figure out how to configure that, so I delete the package.json file before copying the tsc output to its proper folder.

How to 🎩

Run a build, and run the following command:

npm pack 2>&1 | tee packoutput.txt

And then inspect packoutput.txt. Check that the files included in the /esnext/ folder look like this: https://unpkg.com/@shopify/polaris@3.13.0/esnext/

@amrocha amrocha added the 🤖Skip Changelog Causes CI to ignore changelog update check. label May 14, 2019
@BPScott BPScott temporarily deployed to polaris-react-pr-1466 May 14, 2019 00:32 Inactive
@amrocha amrocha added Bug Something is broken and not working as intended in the system. 💣Blocking web labels May 14, 2019
@amrocha amrocha requested review from BPScott and danrosenthal May 14, 2019 00:38
@BPScott BPScott temporarily deployed to polaris-react-pr-1466 May 14, 2019 00:55 Inactive
This file is never imported by any files and its inclusion in the esnext
folder results in npm's files directive not being processed correctly
(i.e. a bunch of files are left out)
@BPScott BPScott temporarily deployed to polaris-react-pr-1466 May 14, 2019 10:35 Inactive
@BPScott
Copy link
Member

BPScott commented May 14, 2019

I've worked out where that package.json was coming from and have stopped it from making its way into build-intermediate in the first place.

It was listed as an explicit include in our tsconfig.json and I guess TS 3.2 now explicitly adds everything listed in your includes to your built output folder, even if you never reference a particular file.

Since the PR that added that in the first place we've changed our approach to how we inject version numbers into the project. Nothing ever imports package.json so it's fine to remove it from the includes array, which in turn stops it appearing in the build-intermediate and esnext folders.

Copy link
Contributor

@danrosenthal danrosenthal left a comment

Choose a reason for hiding this comment

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

@danrosenthal danrosenthal merged commit e6a9c15 into master May 14, 2019
@danrosenthal danrosenthal deleted the fix-ts-build-bug branch May 14, 2019 13:52
@amrocha
Copy link
Contributor Author

amrocha commented May 14, 2019

That would do it, good job figuring this out everyone!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something is broken and not working as intended in the system. 🤖Skip Changelog Causes CI to ignore changelog update check.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants