Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(compiler): persist polyfills on build
in #4317 (b042d8b), a polyfill for node's `path.join` was [removed](https://github.com/ionic-team/stencil/pull/4317/files#diff-734f69edf83052dfd5ce6df10429550680537c6da66ef9b7cfbda11efdff5117L36), but wasn't backfilled with stencil's `@utils` package version in `generate-esm.ts`. without this change, the destination computed for the polyfills is not normalized for users of Windows OS's. when the destination path is not normalized here (but is normalized in other parts of the code), it creates a situation where stencil's in memory-fs both: 1. marks the polyfills to be copied 2. marks the _previous_ polyfills to be removed normally, if we're performing a copy operation, we don't bother with the deletion (as the copy overwrites the existing polyfills). this is important, as stencil performs its copy operations before it performs its deletions. to ensure that a recently copied file is not subsequently deleted, stencil performs a [check on the files it will delete and removes them from the 'to delete' list](https://github.com/ionic-team/stencil/blob/15a7f89f677bad012dd82a088ce64149a7e48a61/src/compiler/sys/in-memory-fs.ts#L1250-L1253) based on the destination filename. since the destination filename on windows is not normalized and the filename for the same file to delete is (normalized), the check fails to acknowledge we're going to copy this file. this causes the following behavior on a stencil build: - if the polyfills directory exists, mark it to be copied, but subsequently delete it - if the polyfills directory does not exist, mark it to be copied. it will not be marked to be deleted because it does not exist on disk when the list of files to delete is calculated (prior to the copy)
- Loading branch information