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

format command sorts "files" property and breaks packages #35

Closed
raijinsetsu opened this issue Jun 19, 2020 · 6 comments
Closed

format command sorts "files" property and breaks packages #35

raijinsetsu opened this issue Jun 19, 2020 · 6 comments

Comments

@raijinsetsu
Copy link

Description

syncpack is reordering the contents of the "files" property which changes the contents of the tarball when using "npm publish" or "npm pack".

example package.json:

{
    files: [
        "dist/",
        "!*.test.*",
        "!__mocks__"
   ]
}

command:
npx syncpack format

result:

{
    files: [
        "!*.test.*",
        "!__mocks__",
        "dist/"
   ]
}

expected result:

{
    files: [
        "dist/",
        "!*.test.*",
        "!__mocks__"
   ]
}

The only work-around is to use .npmignore and remove the files property, but this becomes unmanageable.

Suggested Solution

Do not sort the "files" property.

@raijinsetsu
Copy link
Author

I can submit a PR for this but wanted to get input from other contributors.

Removing the sort for the "files" array would be, technically, backwards incompatible. Should a flag be used to remove "files" from the list of things to be sorted or should I just update constants.ts and remove "files" from it?

@JamieMason
Copy link
Owner

Thanks a lot @raijinsetsu, I think you're right that files should be excluded from the sorting behaviour – this is something I hadn't considered.

Taking a look at the codebase, it should be a case of just removing files from this Array. I happen to have just finished work so I'll do this now and put together a release.

raijinsetsu pushed a commit to raijinsetsu/syncpack that referenced this issue Jun 19, 2020
@raijinsetsu
Copy link
Author

Sounds good to me. I did code the fix in my branch and it was exactly that: removing the one line from the array in constants.ts.

@JamieMason
Copy link
Owner

Great, thanks a lot. I have the fix ready locally and will release soon.

@JamieMason
Copy link
Owner

Should be available now in syncpack@5.0.3

@raijinsetsu
Copy link
Author

raijinsetsu commented Jun 19, 2020 via email

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

No branches or pull requests

2 participants