-
Notifications
You must be signed in to change notification settings - Fork 795
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
bug: typescript imports using windows paths #4543
Comments
@mrginglymus thanks for filing this issue, we recently made a change (in Stencil 4) that changed how paths are normalized in Stencil which is responsible for this regression. I'll take a look at your PR and get this addressed! Thanks again for filing 🙂 |
In #4317 as part of removing in-browser compilation support we removed the polyfills for nodejs built-in modules like `path` which were injected by Rollup during build-time. Although the _main_ purpose of these polyfills was allowing Stencil to run in the browser in the case of the `path` module there was also a secondary purpose which was ensuring that paths were treated the same way across supported platforms (posix + windows). See, for instance, the following lines in the polyfill: https://github.com/ionic-team/stencil/blob/b911f1986a0d583bd1e3cd42cbbca9b255c32f2d/src/compiler/sys/modules/path.ts#L35-L38 These functions basically wrapped the existing path implementation with our `normalizePath` helper, which would ensure that the output paths would be the same on both windows and posix systems (e.g. macOS and linux). When we merged #4317 an effort was made to add `normalizePath` around the codebase where it was thought that various paths being calculated needed to be platform-independent, however, a few locations were missed (in particular, some paths output into typedefs, which would show up as non-posix paths when building on windows). To address the issue we introduce `relative` and `join` functions into the existing path-related `utils` file (which is incidentally renamed) which work similarly to how the patched functions in the old polyfill did. Then several usage sites are changed to import those new utils instead of the 'raw' functions from `path`. Together these changes should ensure that Stencil's output is not platform-dependent. See here for an issue reporting the problem: #4543
@mrginglymus unfortunately I don't have a windows machine handy for testing so I have to rely on our windows CI but I think I have a PR up (#4545) which will address the issue somewhat comprehensively. Is there any chance you could try running a dev build of Stencil to see if it fixes the issue for you? If so, you can install it like this: npm install --save-dev @stencil/[email protected] |
Ah, that looks amazing, thanks so much for the quick and comprehensive response. I'll try and test this afternoon. |
Yes, that build has worked perfectly for me :) |
Excellent, thanks for taking the time to test that out! I'll get that PR reviewed and merged in soon and it will be in the next release if all goes according to plan. |
In #4317 as part of removing in-browser compilation support we removed the polyfills for nodejs built-in modules like `path` which were injected by Rollup during build-time. Although the _main_ purpose of these polyfills was allowing Stencil to run in the browser in the case of the `path` module there was also a secondary purpose which was ensuring that paths were treated the same way across supported platforms (posix + windows). See, for instance, the following lines in the polyfill: https://github.com/ionic-team/stencil/blob/b911f1986a0d583bd1e3cd42cbbca9b255c32f2d/src/compiler/sys/modules/path.ts#L35-L38 These functions basically wrapped the existing path implementation with our `normalizePath` helper, which would ensure that the output paths would be the same on both windows and posix systems (e.g. macOS and linux). When we merged #4317 an effort was made to add `normalizePath` around the codebase where it was thought that various paths being calculated needed to be platform-independent, however, a few locations were missed (in particular, some paths output into typedefs, which would show up as non-posix paths when building on windows). To address the issue we introduce `relative` and `join` functions into the existing path-related `utils` file (which is incidentally renamed) which work similarly to how the patched functions in the old polyfill did. Then several usage sites are changed to import those new utils instead of the 'raw' functions from `path`. Together these changes should ensure that Stencil's output is not platform-dependent. See here for an issue reporting the problem: #4543
In #4317 as part of removing in-browser compilation support we removed the polyfills for nodejs built-in modules like `path` which were injected by Rollup during build-time. Although the _main_ purpose of these polyfills was allowing Stencil to run in the browser in the case of the `path` module there was also a secondary purpose which was ensuring that paths were treated the same way across supported platforms (posix + windows). See, for instance, the following lines in the polyfill: https://github.com/ionic-team/stencil/blob/b911f1986a0d583bd1e3cd42cbbca9b255c32f2d/src/compiler/sys/modules/path.ts#L35-L38 These functions basically wrapped the existing path implementation with our `normalizePath` helper, which would ensure that the output paths would be the same on both windows and posix systems (e.g. macOS and linux). When we merged #4317 an effort was made to add `normalizePath` around the codebase where it was thought that various paths being calculated needed to be platform-independent, however, a few locations were missed (in particular, some paths output into typedefs, which would show up as non-posix paths when building on windows). To address the issue we introduce `relative` and `join` functions into the existing path-related `utils` file (which is incidentally renamed) which work similarly to how the patched functions in the old polyfill did. Then several usage sites are changed to import those new utils instead of the 'raw' functions from `path`. Together these changes should ensure that Stencil's output is not platform-dependent. See here for an issue reporting the problem: #4543
Just merged #4545, so it will be included in the next Stencil release. Thanks for reporting @mrginglymus! |
In #4317 as part of removing in-browser compilation support we removed the polyfills for nodejs built-in modules like `path` which were injected by Rollup during build-time. Although the _main_ purpose of these polyfills was allowing Stencil to run in the browser in the case of the `path` module there was also a secondary purpose which was ensuring that paths were treated the same way across supported platforms (posix + windows). See, for instance, the following lines in the polyfill: https://github.com/ionic-team/stencil/blob/b911f1986a0d583bd1e3cd42cbbca9b255c32f2d/src/compiler/sys/modules/path.ts#L35-L38 These functions basically wrapped the existing path implementation with our `normalizePath` helper, which would ensure that the output paths would be the same on both windows and posix systems (e.g. macOS and linux). When we merged #4317 an effort was made to add `normalizePath` around the codebase where it was thought that various paths being calculated needed to be platform-independent, however, a few locations were missed (in particular, some paths output into typedefs, which would show up as non-posix paths when building on windows). To address the issue we introduce `relative` and `join` functions into the existing path-related `utils` file (which is incidentally renamed) which work similarly to how the patched functions in the old polyfill did. Then several usage sites are changed to import those new utils instead of the 'raw' functions from `path`. Together these changes should ensure that Stencil's output is not platform-dependent. See here for an issue reporting the problem: #4543
The fix for this issue has been released as a part of today's Stencil v4.0.2 release. As a result, I'm going to close this issue. Thanks! |
Prerequisites
Stencil Version
4.0.1
Current Behavior
On Windows, the
dist-custom-elements
target generates adist/components/index.d.ts
with some unescaped windows paths:Expected Behavior
System Info
Steps to Reproduce
On Windows, the
dist-custom-elements
target generates adist/components/index.d.ts
with some unescaped windows pathsCode Reproduction URL
n/a
Additional Information
No response
The text was updated successfully, but these errors were encountered: