From d7d1f7b991b91584cbd439e87f1468a87c00d477 Mon Sep 17 00:00:00 2001 From: Ryan Waskiewicz Date: Thu, 9 Nov 2023 09:30:51 -0500 Subject: [PATCH] fix(compiler): normalize paths on windows this patch ensures that paths are properly normalized by the compiler. this ensures that regardless of the platform (operating system) that a project is compiled on, paths are uniformly treated internally by stencil. this has system-wide reaching effects - from the in-memory filesystem, to configuration/output target validation, and file generation. previously, stencil's in-browser compilation support included a polyfill for the following NodeJS `path` module functions: `join`, `normalize`, `relative` & `resolve`. this polyfill did the following: - it wrapped each of the aforementioned functions in a `normalizePath` function to convert Windows-style path separators (`\\`) to Unix/POSIX-style path separators (`/`) - it overwrote the standard NodeJS `path` implementations for each of these functions. as a result, calling `join` or any of the other three methods, even when importing the method from `path` like below would result in the polyfill being called: ```ts import { join } from 'path'; // this imports the polyfilled `join` // runs the native `path.join`, then normalizes the returned path const filePath = join(part1, part2); ``` while this was 'nice' in that stencil engineers didn't need to think about which implementation of `path` functions they were using, this polyfill made some behavior of the compiler hard to understand. the polyfills were removed in #4317 (b042d8b). this led to calls to the aforementioned functions to call their original implementations, rather than the wrapped implementations: ```ts import { join } from 'path'; // imports Node's `join` // run the native `path.join`, without any normalization const filePath = join(part1, part2); ``` discrepencies arose where parts of the code would explicitly wrap a call to `join()` (or one of its ilk) around a path normalization function. this caused paths to not be uniformly normalized throughout the codebase, leading to errors. since the removal of in-browser compilation, additional pull requests to fix path-related issues on windows have landed in the codebase: - #4545 (cd58d9c) - #4932 (b97dadc) this commit builds on the previous commits by attempting to move stencil's compiler completely over to polyfilled versions of the mentioned `path` functions that are explicitly imported/called. Some of the changes found herein were created/validated using Alice's codemod branch, https://github.com/ionic-team/stencil/pull/4996 Co-authored-by: alicewriteswrongs STENCIL-975 Determine Scope of Path Polyfill Bug, Fix Fixes: #4980 Fixes: #4961 Spun Off: #5036, #5032, #5029 --- src/compiler/app-core/app-es5-disabled.ts | 3 +-- src/compiler/app-core/app-polyfills.ts | 2 +- src/compiler/build/compiler-ctx.ts | 4 ++-- src/compiler/build/watch-build.ts | 4 ++-- src/compiler/bundle/core-resolve-plugin.ts | 4 ++-- src/compiler/bundle/dev-module.ts | 4 ++-- src/compiler/bundle/dev-node-module-resolve.ts | 3 ++- src/compiler/bundle/ext-transforms-plugin.ts | 3 +-- src/compiler/bundle/plugin-helper.ts | 3 +-- src/compiler/bundle/user-index-plugin.ts | 2 +- src/compiler/cache.ts | 2 +- src/compiler/config/config-utils.ts | 4 ++-- .../config/outputs/validate-custom-element.ts | 3 +-- src/compiler/config/outputs/validate-dist.ts | 4 +++- src/compiler/config/outputs/validate-docs.ts | 3 ++- .../config/outputs/validate-hydrate-script.ts | 3 ++- src/compiler/config/outputs/validate-lazy.ts | 3 +-- src/compiler/config/outputs/validate-stats.ts | 4 ++-- src/compiler/config/outputs/validate-www.ts | 3 ++- src/compiler/config/validate-dev-server.ts | 4 ++-- src/compiler/config/validate-paths.ts | 3 ++- src/compiler/config/validate-prerender.ts | 4 ++-- src/compiler/config/validate-service-worker.ts | 4 ++-- src/compiler/config/validate-testing.ts | 4 ++-- src/compiler/docs/generate-doc-data.ts | 4 ++-- src/compiler/docs/json/index.ts | 3 +-- src/compiler/docs/readme/markdown-dependencies.ts | 3 +-- src/compiler/docs/readme/output-docs.ts | 2 +- src/compiler/docs/vscode/index.ts | 3 +-- src/compiler/html/add-script-attr.ts | 2 +- src/compiler/html/html-utils.ts | 2 +- src/compiler/html/inject-module-preloads.ts | 2 +- src/compiler/html/inline-esm-import.ts | 3 +-- src/compiler/html/inline-style-sheets.ts | 2 +- src/compiler/html/update-global-styles-link.ts | 2 +- src/compiler/html/validate-manifest-json.ts | 4 ++-- .../output-targets/copy/assets-copy-tasks.ts | 4 ++-- src/compiler/output-targets/copy/hashed-copy.ts | 3 ++- .../output-targets/copy/local-copy-tasks.ts | 3 ++- src/compiler/output-targets/copy/output-copy.ts | 3 +-- .../output-targets/dist-custom-elements/index.ts | 2 +- .../dist-hydrate-script/generate-hydrate-app.ts | 3 +-- .../dist-hydrate-script/write-hydrate-outputs.ts | 3 ++- .../output-targets/dist-lazy/generate-cjs.ts | 3 +-- .../dist-lazy/generate-lazy-module.ts | 2 +- .../output-targets/dist-lazy/generate-system.ts | 3 +-- .../dist-lazy/write-lazy-entry-module.ts | 3 +-- src/compiler/plugin/plugin.ts | 4 ++-- src/compiler/prerender/prerender-main.ts | 4 ++-- src/compiler/prerender/prerender-optimize.ts | 3 +-- src/compiler/prerender/prerender-worker.ts | 4 ++-- src/compiler/prerender/prerendered-write-path.ts | 3 ++- src/compiler/prerender/robots-txt.ts | 3 +-- src/compiler/prerender/sitemap-xml.ts | 3 +-- src/compiler/style/css-imports.ts | 4 ++-- src/compiler/style/css-to-esm.ts | 4 ++-- src/compiler/style/normalize-styles.ts | 4 ++-- src/compiler/sys/in-memory-fs.ts | 4 ++-- src/compiler/sys/stencil-sys.ts | 4 ++-- src/compiler/sys/typescript/typescript-config.ts | 13 +++++++++++-- .../sys/typescript/typescript-resolve-module.ts | 4 ++-- src/compiler/sys/typescript/typescript-sys.ts | 4 ++-- .../collections/parse-collection-components.ts | 2 +- .../collections/parse-collection-manifest.ts | 3 +-- .../decorators-to-static/style-to-static.ts | 4 ++-- src/compiler/transformers/static-to-meta/import.ts | 4 ++-- .../transformers/static-to-meta/parse-static.ts | 4 ++-- src/compiler/types/generate-app-types.ts | 4 ++-- src/compiler/types/generate-types.ts | 3 +-- src/compiler/types/stencil-types.ts | 4 ++-- src/compiler/types/update-import-refs.ts | 3 ++- src/compiler/types/validate-build-package-json.ts | 12 ++++++++++-- .../types/validate-primary-package-output-target.ts | 3 +-- 73 files changed, 132 insertions(+), 123 deletions(-) diff --git a/src/compiler/app-core/app-es5-disabled.ts b/src/compiler/app-core/app-es5-disabled.ts index b1533c38678..519fd2cce96 100644 --- a/src/compiler/app-core/app-es5-disabled.ts +++ b/src/compiler/app-core/app-es5-disabled.ts @@ -1,5 +1,4 @@ -import { escapeHtml, generatePreamble } from '@utils'; -import { join } from 'path'; +import { escapeHtml, generatePreamble, join } from '@utils'; import type * as d from '../../declarations'; diff --git a/src/compiler/app-core/app-polyfills.ts b/src/compiler/app-core/app-polyfills.ts index 41df3402786..efa49f5d07e 100644 --- a/src/compiler/app-core/app-polyfills.ts +++ b/src/compiler/app-core/app-polyfills.ts @@ -1,4 +1,4 @@ -import { join } from 'path'; +import { join } from '@utils'; import type * as d from '../../declarations'; diff --git a/src/compiler/build/compiler-ctx.ts b/src/compiler/build/compiler-ctx.ts index e9cf50d6b2f..192684c64c8 100644 --- a/src/compiler/build/compiler-ctx.ts +++ b/src/compiler/build/compiler-ctx.ts @@ -1,5 +1,5 @@ -import { noop, normalizePath } from '@utils'; -import { basename, dirname, extname, join } from 'path'; +import { join, noop, normalizePath } from '@utils'; +import { basename, dirname, extname } from 'path'; import type * as d from '../../declarations'; import { buildEvents } from '../events'; diff --git a/src/compiler/build/watch-build.ts b/src/compiler/build/watch-build.ts index 0f63f8126a3..90aac617ccf 100644 --- a/src/compiler/build/watch-build.ts +++ b/src/compiler/build/watch-build.ts @@ -1,5 +1,5 @@ -import { isString } from '@utils'; -import { dirname, resolve } from 'path'; +import { isString, resolve } from '@utils'; +import { dirname } from 'path'; import type ts from 'typescript'; import type * as d from '../../declarations'; diff --git a/src/compiler/bundle/core-resolve-plugin.ts b/src/compiler/bundle/core-resolve-plugin.ts index 46d4ed73858..4b197a709bf 100644 --- a/src/compiler/bundle/core-resolve-plugin.ts +++ b/src/compiler/bundle/core-resolve-plugin.ts @@ -1,5 +1,5 @@ -import { isRemoteUrl, normalizeFsPath, normalizePath } from '@utils'; -import { dirname, join } from 'path'; +import { isRemoteUrl, join, normalizeFsPath, normalizePath } from '@utils'; +import { dirname } from 'path'; import type { Plugin } from 'rollup'; import type * as d from '../../declarations'; diff --git a/src/compiler/bundle/dev-module.ts b/src/compiler/bundle/dev-module.ts index ee87715aee2..ce630568724 100644 --- a/src/compiler/bundle/dev-module.ts +++ b/src/compiler/bundle/dev-module.ts @@ -1,5 +1,5 @@ -import { generatePreamble } from '@utils'; -import { basename, dirname, join, relative } from 'path'; +import { generatePreamble, join, relative } from '@utils'; +import { basename, dirname } from 'path'; import { OutputOptions, rollup } from 'rollup'; import type * as d from '../../declarations'; diff --git a/src/compiler/bundle/dev-node-module-resolve.ts b/src/compiler/bundle/dev-node-module-resolve.ts index 1ab592ede60..58f0c94ff12 100644 --- a/src/compiler/bundle/dev-node-module-resolve.ts +++ b/src/compiler/bundle/dev-node-module-resolve.ts @@ -1,4 +1,5 @@ -import { basename, dirname, join, relative } from 'path'; +import { join, relative } from '@utils'; +import { basename, dirname } from 'path'; import { ResolveIdResult } from 'rollup'; import type * as d from '../../declarations'; diff --git a/src/compiler/bundle/ext-transforms-plugin.ts b/src/compiler/bundle/ext-transforms-plugin.ts index 71c34b58135..64354b3ea45 100644 --- a/src/compiler/bundle/ext-transforms-plugin.ts +++ b/src/compiler/bundle/ext-transforms-plugin.ts @@ -1,5 +1,4 @@ -import { hasError, isOutputTargetDistCollection, normalizeFsPath } from '@utils'; -import { join, relative } from 'path'; +import { hasError, isOutputTargetDistCollection, join, normalizeFsPath, relative } from '@utils'; import type { Plugin } from 'rollup'; import type * as d from '../../declarations'; diff --git a/src/compiler/bundle/plugin-helper.ts b/src/compiler/bundle/plugin-helper.ts index 1aa924f2a95..31792eaa927 100644 --- a/src/compiler/bundle/plugin-helper.ts +++ b/src/compiler/bundle/plugin-helper.ts @@ -1,5 +1,4 @@ -import { buildError } from '@utils'; -import { relative } from 'path'; +import { buildError, relative } from '@utils'; import type * as d from '../../declarations'; diff --git a/src/compiler/bundle/user-index-plugin.ts b/src/compiler/bundle/user-index-plugin.ts index 9053a1b1def..d5c8f52483d 100644 --- a/src/compiler/bundle/user-index-plugin.ts +++ b/src/compiler/bundle/user-index-plugin.ts @@ -1,4 +1,4 @@ -import { join } from 'path'; +import { join } from '@utils'; import type { Plugin } from 'rollup'; import type * as d from '../../declarations'; diff --git a/src/compiler/cache.ts b/src/compiler/cache.ts index 9f5ac749272..a095d2dad21 100644 --- a/src/compiler/cache.ts +++ b/src/compiler/cache.ts @@ -1,4 +1,4 @@ -import { join } from 'path'; +import { join } from '@utils'; import type * as d from '../declarations'; import { InMemoryFileSystem } from './sys/in-memory-fs'; diff --git a/src/compiler/config/config-utils.ts b/src/compiler/config/config-utils.ts index 0a00766d3fc..6c1f78a9407 100644 --- a/src/compiler/config/config-utils.ts +++ b/src/compiler/config/config-utils.ts @@ -1,5 +1,5 @@ -import { isBoolean } from '@utils'; -import { isAbsolute, join } from 'path'; +import { isBoolean, join } from '@utils'; +import { isAbsolute } from 'path'; import type { ConfigFlags } from '../../cli/config-flags'; import type * as d from '../../declarations'; diff --git a/src/compiler/config/outputs/validate-custom-element.ts b/src/compiler/config/outputs/validate-custom-element.ts index fe23cb5e141..61889a81557 100644 --- a/src/compiler/config/outputs/validate-custom-element.ts +++ b/src/compiler/config/outputs/validate-custom-element.ts @@ -1,5 +1,4 @@ -import { COPY, DIST_TYPES, isBoolean, isOutputTargetDistCustomElements } from '@utils'; -import { join } from 'path'; +import { COPY, DIST_TYPES, isBoolean, isOutputTargetDistCustomElements, join } from '@utils'; import type { OutputTarget, diff --git a/src/compiler/config/outputs/validate-dist.ts b/src/compiler/config/outputs/validate-dist.ts index e3850e8b611..e597740fbf2 100644 --- a/src/compiler/config/outputs/validate-dist.ts +++ b/src/compiler/config/outputs/validate-dist.ts @@ -9,8 +9,10 @@ import { isBoolean, isOutputTargetDist, isString, + join, + resolve, } from '@utils'; -import { isAbsolute, join, resolve } from 'path'; +import { isAbsolute } from 'path'; import type * as d from '../../../declarations'; import { getAbsolutePath } from '../config-utils'; diff --git a/src/compiler/config/outputs/validate-docs.ts b/src/compiler/config/outputs/validate-docs.ts index a55d61d400c..5ad083ccb9e 100644 --- a/src/compiler/config/outputs/validate-docs.ts +++ b/src/compiler/config/outputs/validate-docs.ts @@ -8,8 +8,9 @@ import { isOutputTargetDocsReadme, isOutputTargetDocsVscode, isString, + join, } from '@utils'; -import { isAbsolute, join } from 'path'; +import { isAbsolute } from 'path'; import type * as d from '../../../declarations'; import { NOTE } from '../../docs/constants'; diff --git a/src/compiler/config/outputs/validate-hydrate-script.ts b/src/compiler/config/outputs/validate-hydrate-script.ts index 5e6b14b1060..663a47dc159 100644 --- a/src/compiler/config/outputs/validate-hydrate-script.ts +++ b/src/compiler/config/outputs/validate-hydrate-script.ts @@ -5,8 +5,9 @@ import { isOutputTargetHydrate, isOutputTargetWww, isString, + join, } from '@utils'; -import { isAbsolute, join } from 'path'; +import { isAbsolute } from 'path'; import type * as d from '../../../declarations'; diff --git a/src/compiler/config/outputs/validate-lazy.ts b/src/compiler/config/outputs/validate-lazy.ts index 330cd8f8050..01cf70d7859 100644 --- a/src/compiler/config/outputs/validate-lazy.ts +++ b/src/compiler/config/outputs/validate-lazy.ts @@ -1,5 +1,4 @@ -import { DIST_LAZY, isBoolean, isOutputTargetDistLazy } from '@utils'; -import { join } from 'path'; +import { DIST_LAZY, isBoolean, isOutputTargetDistLazy, join } from '@utils'; import type * as d from '../../../declarations'; import { getAbsolutePath } from '../config-utils'; diff --git a/src/compiler/config/outputs/validate-stats.ts b/src/compiler/config/outputs/validate-stats.ts index 59f0f115e26..9da42f8b183 100644 --- a/src/compiler/config/outputs/validate-stats.ts +++ b/src/compiler/config/outputs/validate-stats.ts @@ -1,5 +1,5 @@ -import { isOutputTargetStats, STATS } from '@utils'; -import { isAbsolute, join } from 'path'; +import { isOutputTargetStats, join, STATS } from '@utils'; +import { isAbsolute } from 'path'; import type * as d from '../../../declarations'; diff --git a/src/compiler/config/outputs/validate-www.ts b/src/compiler/config/outputs/validate-www.ts index 86e7108268f..ce9ffe664b1 100644 --- a/src/compiler/config/outputs/validate-www.ts +++ b/src/compiler/config/outputs/validate-www.ts @@ -7,9 +7,10 @@ import { isOutputTargetDist, isOutputTargetWww, isString, + join, WWW, } from '@utils'; -import { isAbsolute, join } from 'path'; +import { isAbsolute } from 'path'; import type * as d from '../../../declarations'; import { getAbsolutePath } from '../config-utils'; diff --git a/src/compiler/config/validate-dev-server.ts b/src/compiler/config/validate-dev-server.ts index 8e8b8baacb0..14ebdea7168 100644 --- a/src/compiler/config/validate-dev-server.ts +++ b/src/compiler/config/validate-dev-server.ts @@ -1,5 +1,5 @@ -import { buildError, isBoolean, isNumber, isOutputTargetWww, isString, normalizePath } from '@utils'; -import { isAbsolute, join } from 'path'; +import { buildError, isBoolean, isNumber, isOutputTargetWww, isString, join, normalizePath } from '@utils'; +import { isAbsolute } from 'path'; import type * as d from '../../declarations'; diff --git a/src/compiler/config/validate-paths.ts b/src/compiler/config/validate-paths.ts index 4208d88d561..89f41703758 100644 --- a/src/compiler/config/validate-paths.ts +++ b/src/compiler/config/validate-paths.ts @@ -1,4 +1,5 @@ -import { isAbsolute, join } from 'path'; +import { join } from '@utils'; +import { isAbsolute } from 'path'; import type * as d from '../../declarations'; diff --git a/src/compiler/config/validate-prerender.ts b/src/compiler/config/validate-prerender.ts index c689f4d1976..78c52343cdb 100644 --- a/src/compiler/config/validate-prerender.ts +++ b/src/compiler/config/validate-prerender.ts @@ -1,5 +1,5 @@ -import { buildError, isString, normalizePath } from '@utils'; -import { isAbsolute, join } from 'path'; +import { buildError, isString, join, normalizePath } from '@utils'; +import { isAbsolute } from 'path'; import type * as d from '../../declarations'; diff --git a/src/compiler/config/validate-service-worker.ts b/src/compiler/config/validate-service-worker.ts index e7165afbef2..de067b309d3 100644 --- a/src/compiler/config/validate-service-worker.ts +++ b/src/compiler/config/validate-service-worker.ts @@ -1,5 +1,5 @@ -import { isString } from '@utils'; -import { isAbsolute, join } from 'path'; +import { isString, join } from '@utils'; +import { isAbsolute } from 'path'; import type * as d from '../../declarations'; diff --git a/src/compiler/config/validate-testing.ts b/src/compiler/config/validate-testing.ts index 6e7da70913a..0df19313bbb 100644 --- a/src/compiler/config/validate-testing.ts +++ b/src/compiler/config/validate-testing.ts @@ -1,5 +1,5 @@ -import { buildError, isOutputTargetDist, isOutputTargetWww, isString } from '@utils'; -import { basename, dirname, isAbsolute, join } from 'path'; +import { buildError, isOutputTargetDist, isOutputTargetWww, isString, join } from '@utils'; +import { basename, dirname, isAbsolute } from 'path'; import type * as d from '../../declarations'; import { isLocalModule } from '../sys/resolve/resolve-utils'; diff --git a/src/compiler/docs/generate-doc-data.ts b/src/compiler/docs/generate-doc-data.ts index 549ad3f7880..a82e3b24107 100644 --- a/src/compiler/docs/generate-doc-data.ts +++ b/src/compiler/docs/generate-doc-data.ts @@ -1,5 +1,5 @@ -import { flatOne, isOutputTargetDocsJson, normalizePath, sortBy, unique } from '@utils'; -import { basename, dirname, join, relative } from 'path'; +import { flatOne, isOutputTargetDocsJson, join, normalizePath, relative, sortBy, unique } from '@utils'; +import { basename, dirname } from 'path'; import type * as d from '../../declarations'; import { JsonDocsValue } from '../../declarations'; diff --git a/src/compiler/docs/json/index.ts b/src/compiler/docs/json/index.ts index e8005c34f96..8eadc2ee644 100644 --- a/src/compiler/docs/json/index.ts +++ b/src/compiler/docs/json/index.ts @@ -1,5 +1,4 @@ -import { isOutputTargetDocsJson } from '@utils'; -import { join } from 'path'; +import { isOutputTargetDocsJson, join } from '@utils'; import type * as d from '../../../declarations'; diff --git a/src/compiler/docs/readme/markdown-dependencies.ts b/src/compiler/docs/readme/markdown-dependencies.ts index 86f256b55b5..6aad6d8c60a 100644 --- a/src/compiler/docs/readme/markdown-dependencies.ts +++ b/src/compiler/docs/readme/markdown-dependencies.ts @@ -1,5 +1,4 @@ -import { normalizePath } from '@utils'; -import { relative } from 'path'; +import { normalizePath, relative } from '@utils'; import type * as d from '../../../declarations'; diff --git a/src/compiler/docs/readme/output-docs.ts b/src/compiler/docs/readme/output-docs.ts index a30a8f98dc9..7b5962779ef 100644 --- a/src/compiler/docs/readme/output-docs.ts +++ b/src/compiler/docs/readme/output-docs.ts @@ -1,4 +1,4 @@ -import { join, relative } from 'path'; +import { join, relative } from '@utils'; import type * as d from '../../../declarations'; import { AUTO_GENERATE_COMMENT } from '../constants'; diff --git a/src/compiler/docs/vscode/index.ts b/src/compiler/docs/vscode/index.ts index 17f1c83538e..41a1794110f 100644 --- a/src/compiler/docs/vscode/index.ts +++ b/src/compiler/docs/vscode/index.ts @@ -1,5 +1,4 @@ -import { isOutputTargetDocsVscode } from '@utils'; -import { join } from 'path'; +import { isOutputTargetDocsVscode, join } from '@utils'; import type * as d from '../../../declarations'; import { getNameText } from '../generate-doc-data'; diff --git a/src/compiler/html/add-script-attr.ts b/src/compiler/html/add-script-attr.ts index 2a57f6a6353..007056bf382 100644 --- a/src/compiler/html/add-script-attr.ts +++ b/src/compiler/html/add-script-attr.ts @@ -1,4 +1,4 @@ -import { join } from 'path'; +import { join } from '@utils'; import type * as d from '../../declarations'; import { getAbsoluteBuildDir } from './html-utils'; diff --git a/src/compiler/html/html-utils.ts b/src/compiler/html/html-utils.ts index ddf66a8a09e..9953030f6cd 100644 --- a/src/compiler/html/html-utils.ts +++ b/src/compiler/html/html-utils.ts @@ -1,4 +1,4 @@ -import { join, relative } from 'path'; +import { join, relative } from '@utils'; import type * as d from '../../declarations'; diff --git a/src/compiler/html/inject-module-preloads.ts b/src/compiler/html/inject-module-preloads.ts index 1e8385973c4..9d3d6e4eada 100644 --- a/src/compiler/html/inject-module-preloads.ts +++ b/src/compiler/html/inject-module-preloads.ts @@ -1,4 +1,4 @@ -import { join } from 'path'; +import { join } from '@utils'; import type * as d from '../../declarations'; import { getAbsoluteBuildDir } from './html-utils'; diff --git a/src/compiler/html/inline-esm-import.ts b/src/compiler/html/inline-esm-import.ts index 55747a02284..3f417164790 100644 --- a/src/compiler/html/inline-esm-import.ts +++ b/src/compiler/html/inline-esm-import.ts @@ -1,5 +1,4 @@ -import { isString } from '@utils'; -import { join } from 'path'; +import { isString, join } from '@utils'; import ts from 'typescript'; import type * as d from '../../declarations'; diff --git a/src/compiler/html/inline-style-sheets.ts b/src/compiler/html/inline-style-sheets.ts index 9bebddf84fe..23b980ccd82 100644 --- a/src/compiler/html/inline-style-sheets.ts +++ b/src/compiler/html/inline-style-sheets.ts @@ -1,4 +1,4 @@ -import { join } from 'path'; +import { join } from '@utils'; import type * as d from '../../declarations'; diff --git a/src/compiler/html/update-global-styles-link.ts b/src/compiler/html/update-global-styles-link.ts index ab68c7fa8c4..29d0aeb19db 100644 --- a/src/compiler/html/update-global-styles-link.ts +++ b/src/compiler/html/update-global-styles-link.ts @@ -1,4 +1,4 @@ -import { join } from 'path'; +import { join } from '@utils'; import type * as d from '../../declarations'; import { getAbsoluteBuildDir } from './html-utils'; diff --git a/src/compiler/html/validate-manifest-json.ts b/src/compiler/html/validate-manifest-json.ts index edbc0aa313a..7a5a2a89c0e 100644 --- a/src/compiler/html/validate-manifest-json.ts +++ b/src/compiler/html/validate-manifest-json.ts @@ -1,5 +1,5 @@ -import { buildError, buildJsonFileError, isOutputTargetWww } from '@utils'; -import { dirname, join } from 'path'; +import { buildError, buildJsonFileError, isOutputTargetWww, join } from '@utils'; +import { dirname } from 'path'; import type * as d from '../../declarations'; diff --git a/src/compiler/output-targets/copy/assets-copy-tasks.ts b/src/compiler/output-targets/copy/assets-copy-tasks.ts index d1b74515f95..31ec668fa9c 100644 --- a/src/compiler/output-targets/copy/assets-copy-tasks.ts +++ b/src/compiler/output-targets/copy/assets-copy-tasks.ts @@ -1,5 +1,5 @@ -import { normalizePath } from '@utils'; -import { dirname, join, relative } from 'path'; +import { join, normalizePath, relative } from '@utils'; +import { dirname } from 'path'; import type * as d from '../../../declarations'; diff --git a/src/compiler/output-targets/copy/hashed-copy.ts b/src/compiler/output-targets/copy/hashed-copy.ts index b86c42efffc..60f1f7a9463 100644 --- a/src/compiler/output-targets/copy/hashed-copy.ts +++ b/src/compiler/output-targets/copy/hashed-copy.ts @@ -1,4 +1,5 @@ -import { dirname, extname, join } from 'path'; +import { join } from '@utils'; +import { dirname, extname } from 'path'; import type * as d from '../../../declarations'; diff --git a/src/compiler/output-targets/copy/local-copy-tasks.ts b/src/compiler/output-targets/copy/local-copy-tasks.ts index d87acb81b79..128f884ddb8 100644 --- a/src/compiler/output-targets/copy/local-copy-tasks.ts +++ b/src/compiler/output-targets/copy/local-copy-tasks.ts @@ -1,4 +1,5 @@ -import { isAbsolute, join } from 'path'; +import { join } from '@utils'; +import { isAbsolute } from 'path'; import type * as d from '../../../declarations'; diff --git a/src/compiler/output-targets/copy/output-copy.ts b/src/compiler/output-targets/copy/output-copy.ts index 65360e6e365..32c934e21d3 100644 --- a/src/compiler/output-targets/copy/output-copy.ts +++ b/src/compiler/output-targets/copy/output-copy.ts @@ -1,6 +1,5 @@ -import { buildError, isGlob, isOutputTargetCopy, normalizePath } from '@utils'; +import { buildError, isGlob, isOutputTargetCopy, join, normalizePath } from '@utils'; import minimatch from 'minimatch'; -import { join } from 'path'; import type * as d from '../../../declarations'; import { canSkipAssetsCopy, getComponentAssetsCopyTasks } from './assets-copy-tasks'; diff --git a/src/compiler/output-targets/dist-custom-elements/index.ts b/src/compiler/output-targets/dist-custom-elements/index.ts index 2f45865c466..8d70c15977b 100644 --- a/src/compiler/output-targets/dist-custom-elements/index.ts +++ b/src/compiler/output-targets/dist-custom-elements/index.ts @@ -6,9 +6,9 @@ import { hasError, isOutputTargetDistCustomElements, isString, + join, rollupToStencilSourceMap, } from '@utils'; -import { join } from 'path'; import ts from 'typescript'; import type * as d from '../../../declarations'; diff --git a/src/compiler/output-targets/dist-hydrate-script/generate-hydrate-app.ts b/src/compiler/output-targets/dist-hydrate-script/generate-hydrate-app.ts index ca9aab347ec..85e9a13dc5a 100644 --- a/src/compiler/output-targets/dist-hydrate-script/generate-hydrate-app.ts +++ b/src/compiler/output-targets/dist-hydrate-script/generate-hydrate-app.ts @@ -1,6 +1,5 @@ -import { catchError, createOnWarnFn, generatePreamble, loadRollupDiagnostics } from '@utils'; +import { catchError, createOnWarnFn, generatePreamble, join, loadRollupDiagnostics } from '@utils'; import MagicString from 'magic-string'; -import { join } from 'path'; import { RollupOptions } from 'rollup'; import { rollup } from 'rollup'; diff --git a/src/compiler/output-targets/dist-hydrate-script/write-hydrate-outputs.ts b/src/compiler/output-targets/dist-hydrate-script/write-hydrate-outputs.ts index 0383a9e1a57..33aef31c8e7 100644 --- a/src/compiler/output-targets/dist-hydrate-script/write-hydrate-outputs.ts +++ b/src/compiler/output-targets/dist-hydrate-script/write-hydrate-outputs.ts @@ -1,4 +1,5 @@ -import { basename, join } from 'path'; +import { join } from '@utils'; +import { basename } from 'path'; import type { RollupOutput } from 'rollup'; import type * as d from '../../../declarations'; diff --git a/src/compiler/output-targets/dist-lazy/generate-cjs.ts b/src/compiler/output-targets/dist-lazy/generate-cjs.ts index 45a1bd06b88..70498cac678 100644 --- a/src/compiler/output-targets/dist-lazy/generate-cjs.ts +++ b/src/compiler/output-targets/dist-lazy/generate-cjs.ts @@ -1,5 +1,4 @@ -import { generatePreamble, relativeImport } from '@utils'; -import { join } from 'path'; +import { generatePreamble, join, relativeImport } from '@utils'; import type { OutputOptions, RollupBuild } from 'rollup'; import type * as d from '../../../declarations'; diff --git a/src/compiler/output-targets/dist-lazy/generate-lazy-module.ts b/src/compiler/output-targets/dist-lazy/generate-lazy-module.ts index b860ccb0b4e..74e9c3d0d4d 100644 --- a/src/compiler/output-targets/dist-lazy/generate-lazy-module.ts +++ b/src/compiler/output-targets/dist-lazy/generate-lazy-module.ts @@ -2,10 +2,10 @@ import { formatComponentRuntimeMeta, getSourceMappingUrlForEndOfFile, hasDependency, + join, rollupToStencilSourceMap, stringifyRuntimeData, } from '@utils'; -import { join } from 'path'; import type { SourceMap as RollupSourceMap } from 'rollup'; import type * as d from '../../../declarations'; diff --git a/src/compiler/output-targets/dist-lazy/generate-system.ts b/src/compiler/output-targets/dist-lazy/generate-system.ts index d8304a34065..5a236127556 100644 --- a/src/compiler/output-targets/dist-lazy/generate-system.ts +++ b/src/compiler/output-targets/dist-lazy/generate-system.ts @@ -1,5 +1,4 @@ -import { generatePreamble, relativeImport } from '@utils'; -import { join } from 'path'; +import { generatePreamble, join, relativeImport } from '@utils'; import type { OutputOptions, RollupBuild } from 'rollup'; import type * as d from '../../../declarations'; diff --git a/src/compiler/output-targets/dist-lazy/write-lazy-entry-module.ts b/src/compiler/output-targets/dist-lazy/write-lazy-entry-module.ts index dae558ad50c..36cc6289373 100644 --- a/src/compiler/output-targets/dist-lazy/write-lazy-entry-module.ts +++ b/src/compiler/output-targets/dist-lazy/write-lazy-entry-module.ts @@ -1,5 +1,4 @@ -import { getSourceMappingUrlForEndOfFile } from '@utils'; -import { join } from 'path'; +import { getSourceMappingUrlForEndOfFile, join } from '@utils'; import type * as d from '../../../declarations'; diff --git a/src/compiler/plugin/plugin.ts b/src/compiler/plugin/plugin.ts index 023be394778..c5874f28452 100644 --- a/src/compiler/plugin/plugin.ts +++ b/src/compiler/plugin/plugin.ts @@ -1,5 +1,5 @@ -import { buildError, catchError, isFunction, isOutputTargetDocs, isString } from '@utils'; -import { basename, relative } from 'path'; +import { buildError, catchError, isFunction, isOutputTargetDocs, isString, relative } from '@utils'; +import { basename } from 'path'; import type * as d from '../../declarations'; import { PluginCtx, PluginTransformResults } from '../../declarations'; diff --git a/src/compiler/prerender/prerender-main.ts b/src/compiler/prerender/prerender-main.ts index adfb618e752..ed6f4eab44a 100644 --- a/src/compiler/prerender/prerender-main.ts +++ b/src/compiler/prerender/prerender-main.ts @@ -1,5 +1,5 @@ -import { buildError, catchError, hasError, isOutputTargetWww, isString } from '@utils'; -import { isAbsolute, join } from 'path'; +import { buildError, catchError, hasError, isOutputTargetWww, isString, join } from '@utils'; +import { isAbsolute } from 'path'; import type * as d from '../../declarations'; import { createHydrateBuildId } from '../../hydrate/runner/render-utils'; diff --git a/src/compiler/prerender/prerender-optimize.ts b/src/compiler/prerender/prerender-optimize.ts index 12d496c999c..64e15886cb4 100644 --- a/src/compiler/prerender/prerender-optimize.ts +++ b/src/compiler/prerender/prerender-optimize.ts @@ -1,5 +1,4 @@ -import { catchError, flatOne, isString, unique } from '@utils'; -import { join } from 'path'; +import { catchError, flatOne, isString, join, unique } from '@utils'; import type * as d from '../../declarations'; import { injectModulePreloads } from '../html/inject-module-preloads'; diff --git a/src/compiler/prerender/prerender-worker.ts b/src/compiler/prerender/prerender-worker.ts index d69c96e06df..c884a52c163 100644 --- a/src/compiler/prerender/prerender-worker.ts +++ b/src/compiler/prerender/prerender-worker.ts @@ -1,5 +1,5 @@ -import { catchError, isFunction, isPromise, isRootPath, normalizePath } from '@utils'; -import { dirname, join } from 'path'; +import { catchError, isFunction, isPromise, isRootPath, join, normalizePath } from '@utils'; +import { dirname } from 'path'; import type * as d from '../../declarations'; import { crawlAnchorsForNextUrls } from './crawl-urls'; diff --git a/src/compiler/prerender/prerendered-write-path.ts b/src/compiler/prerender/prerendered-write-path.ts index d82a6352e89..5c94fb00aa7 100644 --- a/src/compiler/prerender/prerendered-write-path.ts +++ b/src/compiler/prerender/prerendered-write-path.ts @@ -1,3 +1,4 @@ +import { join } from '@utils'; import path from 'path'; import type * as d from '../../declarations'; @@ -46,5 +47,5 @@ export const getWriteFilePathFromUrlPath = (manager: d.PrerenderManager, inputHr pathParts.push(fileName); // figure out the directory where this file will be saved - return path.join(manager.outputTarget.appDir, ...pathParts); + return join(manager.outputTarget.appDir, ...pathParts); }; diff --git a/src/compiler/prerender/robots-txt.ts b/src/compiler/prerender/robots-txt.ts index 70a2e08374a..28c9945e870 100644 --- a/src/compiler/prerender/robots-txt.ts +++ b/src/compiler/prerender/robots-txt.ts @@ -1,5 +1,4 @@ -import { catchError } from '@utils'; -import { join } from 'path'; +import { catchError, join } from '@utils'; import type * as d from '../../declarations'; import { getSitemapUrls } from './sitemap-xml'; diff --git a/src/compiler/prerender/sitemap-xml.ts b/src/compiler/prerender/sitemap-xml.ts index 899e00fc640..b00b6b4d155 100644 --- a/src/compiler/prerender/sitemap-xml.ts +++ b/src/compiler/prerender/sitemap-xml.ts @@ -1,5 +1,4 @@ -import { catchError } from '@utils'; -import { join } from 'path'; +import { catchError, join } from '@utils'; import type * as d from '../../declarations'; diff --git a/src/compiler/style/css-imports.ts b/src/compiler/style/css-imports.ts index c099b0c1e52..3e20b7aa25c 100644 --- a/src/compiler/style/css-imports.ts +++ b/src/compiler/style/css-imports.ts @@ -1,5 +1,5 @@ -import { buildError, normalizePath } from '@utils'; -import { basename, dirname, isAbsolute, join } from 'path'; +import { buildError, join, normalizePath } from '@utils'; +import { basename, dirname, isAbsolute } from 'path'; import type * as d from '../../declarations'; import { parseStyleDocs } from '../docs/style-docs'; diff --git a/src/compiler/style/css-to-esm.ts b/src/compiler/style/css-to-esm.ts index bf0ea9effd6..5d0389d2cca 100644 --- a/src/compiler/style/css-to-esm.ts +++ b/src/compiler/style/css-to-esm.ts @@ -1,4 +1,4 @@ -import { catchError, createJsVarName, DEFAULT_STYLE_MODE, hasError, isString, normalizePath } from '@utils'; +import { catchError, createJsVarName, DEFAULT_STYLE_MODE, hasError, isString, normalizePath, resolve } from '@utils'; import MagicString from 'magic-string'; import path from 'path'; @@ -243,7 +243,7 @@ const getCssToEsmImports = ( cssImportData.filePath = normalizePath(cssImportData.url); } else { // relative path - cssImportData.filePath = normalizePath(path.resolve(dir, cssImportData.url)); + cssImportData.filePath = normalizePath(resolve(dir, cssImportData.url)); } cssImportData.varName = createCssVarName(cssImportData.filePath, modeName); diff --git a/src/compiler/style/normalize-styles.ts b/src/compiler/style/normalize-styles.ts index e84269329fb..b43af888c73 100644 --- a/src/compiler/style/normalize-styles.ts +++ b/src/compiler/style/normalize-styles.ts @@ -1,5 +1,5 @@ -import { DEFAULT_STYLE_MODE, normalizePath } from '@utils'; -import { dirname, isAbsolute, join, relative } from 'path'; +import { DEFAULT_STYLE_MODE, join, normalizePath, relative } from '@utils'; +import { dirname, isAbsolute } from 'path'; import type * as d from '../../declarations'; diff --git a/src/compiler/sys/in-memory-fs.ts b/src/compiler/sys/in-memory-fs.ts index 8d329a21eaa..40284f4a8ed 100644 --- a/src/compiler/sys/in-memory-fs.ts +++ b/src/compiler/sys/in-memory-fs.ts @@ -1,6 +1,6 @@ import type * as d from '@stencil/core/internal'; -import { isIterable, isString, normalizePath } from '@utils'; -import { basename, dirname, relative } from 'path'; +import { isIterable, isString, normalizePath, relative } from '@utils'; +import { basename, dirname } from 'path'; /** * An in-memory FS which proxies the underlying OS filesystem using a simple diff --git a/src/compiler/sys/stencil-sys.ts b/src/compiler/sys/stencil-sys.ts index 698ed31cf2b..c802a2cfce1 100644 --- a/src/compiler/sys/stencil-sys.ts +++ b/src/compiler/sys/stencil-sys.ts @@ -1,7 +1,7 @@ import { createNodeLogger } from '@sys-api-node'; -import { isRootPath, normalizePath } from '@utils'; +import { isRootPath, join, normalizePath } from '@utils'; import * as os from 'os'; -import path, { basename, dirname, join } from 'path'; +import path, { basename, dirname } from 'path'; import * as process from 'process'; import type { diff --git a/src/compiler/sys/typescript/typescript-config.ts b/src/compiler/sys/typescript/typescript-config.ts index 7abfa4268bf..7d269910d2c 100644 --- a/src/compiler/sys/typescript/typescript-config.ts +++ b/src/compiler/sys/typescript/typescript-config.ts @@ -1,5 +1,14 @@ -import { buildError, buildWarn, catchError, isString, loadTypeScriptDiagnostic, normalizePath } from '@utils'; -import { isAbsolute, join, relative } from 'path'; +import { + buildError, + buildWarn, + catchError, + isString, + join, + loadTypeScriptDiagnostic, + normalizePath, + relative, +} from '@utils'; +import { isAbsolute } from 'path'; import ts from 'typescript'; import type * as d from '../../../declarations'; diff --git a/src/compiler/sys/typescript/typescript-resolve-module.ts b/src/compiler/sys/typescript/typescript-resolve-module.ts index 56099014afc..58d29449957 100644 --- a/src/compiler/sys/typescript/typescript-resolve-module.ts +++ b/src/compiler/sys/typescript/typescript-resolve-module.ts @@ -1,5 +1,5 @@ -import { isString, normalizePath } from '@utils'; -import { basename, dirname, join, resolve } from 'path'; +import { isString, join, normalizePath, resolve } from '@utils'; +import { basename, dirname } from 'path'; import ts from 'typescript'; import type * as d from '../../../declarations'; diff --git a/src/compiler/sys/typescript/typescript-sys.ts b/src/compiler/sys/typescript/typescript-sys.ts index 63a0bf5bf0c..db5d4eba9b0 100644 --- a/src/compiler/sys/typescript/typescript-sys.ts +++ b/src/compiler/sys/typescript/typescript-sys.ts @@ -1,5 +1,5 @@ -import { isRemoteUrl, isString, noop, normalizePath } from '@utils'; -import { basename, resolve } from 'path'; +import { isRemoteUrl, isString, noop, normalizePath, resolve } from '@utils'; +import { basename } from 'path'; import ts from 'typescript'; import type * as d from '../../../declarations'; diff --git a/src/compiler/transformers/collections/parse-collection-components.ts b/src/compiler/transformers/collections/parse-collection-components.ts index 91ad5b0d323..d7eeb96c1c6 100644 --- a/src/compiler/transformers/collections/parse-collection-components.ts +++ b/src/compiler/transformers/collections/parse-collection-components.ts @@ -1,4 +1,4 @@ -import { join } from 'path'; +import { join } from '@utils'; import ts from 'typescript'; import type * as d from '../../../declarations'; diff --git a/src/compiler/transformers/collections/parse-collection-manifest.ts b/src/compiler/transformers/collections/parse-collection-manifest.ts index 3d9d2e4da11..c15c6762f17 100644 --- a/src/compiler/transformers/collections/parse-collection-manifest.ts +++ b/src/compiler/transformers/collections/parse-collection-manifest.ts @@ -1,5 +1,4 @@ -import { normalizePath } from '@utils'; -import { join } from 'path'; +import { join, normalizePath } from '@utils'; import type * as d from '../../../declarations'; import { parseCollectionComponents, transpileCollectionModule } from './parse-collection-components'; diff --git a/src/compiler/transformers/decorators-to-static/style-to-static.ts b/src/compiler/transformers/decorators-to-static/style-to-static.ts index 2ece72b5656..277782d266f 100644 --- a/src/compiler/transformers/decorators-to-static/style-to-static.ts +++ b/src/compiler/transformers/decorators-to-static/style-to-static.ts @@ -1,5 +1,5 @@ -import { DEFAULT_STYLE_MODE } from '@utils'; -import { basename, dirname, extname, join } from 'path'; +import { DEFAULT_STYLE_MODE, join } from '@utils'; +import { basename, dirname, extname } from 'path'; import ts from 'typescript'; import type * as d from '../../../declarations'; diff --git a/src/compiler/transformers/static-to-meta/import.ts b/src/compiler/transformers/static-to-meta/import.ts index dc903ec5a2d..77107333202 100644 --- a/src/compiler/transformers/static-to-meta/import.ts +++ b/src/compiler/transformers/static-to-meta/import.ts @@ -1,5 +1,5 @@ -import { normalizePath } from '@utils'; -import { isAbsolute, resolve } from 'path'; +import { normalizePath, resolve } from '@utils'; +import { isAbsolute } from 'path'; import ts from 'typescript'; import type * as d from '../../../declarations'; diff --git a/src/compiler/transformers/static-to-meta/parse-static.ts b/src/compiler/transformers/static-to-meta/parse-static.ts index 9e3cf5da67d..0d83c515d59 100644 --- a/src/compiler/transformers/static-to-meta/parse-static.ts +++ b/src/compiler/transformers/static-to-meta/parse-static.ts @@ -1,5 +1,5 @@ -import { normalizePath } from '@utils'; -import { basename, dirname, join } from 'path'; +import { join, normalizePath } from '@utils'; +import { basename, dirname } from 'path'; import ts from 'typescript'; import type * as d from '../../../declarations'; diff --git a/src/compiler/types/generate-app-types.ts b/src/compiler/types/generate-app-types.ts index 2c153ee919d..c78df43fe1d 100644 --- a/src/compiler/types/generate-app-types.ts +++ b/src/compiler/types/generate-app-types.ts @@ -1,5 +1,5 @@ -import { addDocBlock, GENERATED_DTS, getComponentsDtsSrcFilePath, normalizePath } from '@utils'; -import { isAbsolute, relative, resolve } from 'path'; +import { addDocBlock, GENERATED_DTS, getComponentsDtsSrcFilePath, normalizePath, relative, resolve } from '@utils'; +import { isAbsolute } from 'path'; import type * as d from '../../declarations'; import { generateComponentTypes } from './generate-component-types'; diff --git a/src/compiler/types/generate-types.ts b/src/compiler/types/generate-types.ts index 3419219c293..dc936002322 100644 --- a/src/compiler/types/generate-types.ts +++ b/src/compiler/types/generate-types.ts @@ -1,5 +1,4 @@ -import { isDtsFile } from '@utils'; -import { join, relative } from 'path'; +import { isDtsFile, join, relative } from '@utils'; import type * as d from '../../declarations'; import { generateCustomElementsTypes } from '../output-targets/dist-custom-elements/custom-elements-types'; diff --git a/src/compiler/types/stencil-types.ts b/src/compiler/types/stencil-types.ts index d7842b3f992..e5a1b9b669d 100644 --- a/src/compiler/types/stencil-types.ts +++ b/src/compiler/types/stencil-types.ts @@ -1,5 +1,5 @@ -import { isOutputTargetDistTypes, normalizePath } from '@utils'; -import { dirname, join, relative, resolve } from 'path'; +import { isOutputTargetDistTypes, join, normalizePath, relative, resolve } from '@utils'; +import { dirname } from 'path'; import type * as d from '../../declarations'; import { FsWriteResults } from '../sys/in-memory-fs'; diff --git a/src/compiler/types/update-import-refs.ts b/src/compiler/types/update-import-refs.ts index 9d0c323ddb4..a534bdd59e5 100644 --- a/src/compiler/types/update-import-refs.ts +++ b/src/compiler/types/update-import-refs.ts @@ -1,4 +1,5 @@ -import { dirname, resolve } from 'path'; +import { resolve } from '@utils'; +import { dirname } from 'path'; import ts from 'typescript'; import type * as d from '../../declarations'; diff --git a/src/compiler/types/validate-build-package-json.ts b/src/compiler/types/validate-build-package-json.ts index f2257404509..715813bc955 100644 --- a/src/compiler/types/validate-build-package-json.ts +++ b/src/compiler/types/validate-build-package-json.ts @@ -1,5 +1,13 @@ -import { COLLECTION_MANIFEST_FILE_NAME, isGlob, isOutputTargetDistCollection, isString, normalizePath } from '@utils'; -import { dirname, join, relative } from 'path'; +import { + COLLECTION_MANIFEST_FILE_NAME, + isGlob, + isOutputTargetDistCollection, + isString, + join, + normalizePath, + relative, +} from '@utils'; +import { dirname } from 'path'; import type * as d from '../../declarations'; import { packageJsonError, packageJsonWarn } from './package-json-log-utils'; diff --git a/src/compiler/types/validate-primary-package-output-target.ts b/src/compiler/types/validate-primary-package-output-target.ts index 8c2196ad6c7..844cf059bfd 100644 --- a/src/compiler/types/validate-primary-package-output-target.ts +++ b/src/compiler/types/validate-primary-package-output-target.ts @@ -1,5 +1,4 @@ -import { buildWarn, isEligiblePrimaryPackageOutputTarget, isString, normalizePath } from '@utils'; -import { join, relative } from 'path'; +import { buildWarn, isEligiblePrimaryPackageOutputTarget, isString, join, normalizePath, relative } from '@utils'; import type * as d from '../../declarations'; import { packageJsonError, packageJsonWarn } from './package-json-log-utils';