diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-03-04 22:31:38 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-05 02:31:38 +0000 |
commit | b40086fd7da3729d1d59b312c89ee57747fc66a9 (patch) | |
tree | 991583010635feab13fae77e7c8a35fef0a09095 /ext/node/polyfills/path | |
parent | 01028fcdf4f379a7285cc15079306e3ac31edcc1 (diff) |
refactor(core): include_js_files! 'dir' option doesn't change specifiers (#18019)
This commit changes "include_js_files!" macro from "deno_core"
in a way that "dir" option doesn't cause specifiers to be rewritten
to include it.
Example:
```
include_js_files! {
dir "js",
"hello.js",
}
```
The above definition required embedders to use:
`import ... from "internal:<ext_name>/js/hello.js"`.
But with this change, the "js" directory in which the files are stored
is an implementation detail, which for embedders results in:
`import ... from "internal:<ext_name>/hello.js"`.
The directory the files are stored in, is an implementation detail and
in some cases might result in a significant size difference for the
snapshot. As an example, in "deno_node" extension, we store the
source code in "polyfills" directory; which resulted in each specifier
to look like "internal:deno_node/polyfills/<module_name>", but with
this change it's "internal:deno_node/<module_name>".
Given that "deno_node" has over 100 files, many of them having
several import specifiers to the same extension, this change removes
10 characters from each import specifier.
Diffstat (limited to 'ext/node/polyfills/path')
-rw-r--r-- | ext/node/polyfills/path/_util.ts | 6 | ||||
-rw-r--r-- | ext/node/polyfills/path/common.ts | 2 | ||||
-rw-r--r-- | ext/node/polyfills/path/glob.ts | 13 | ||||
-rw-r--r-- | ext/node/polyfills/path/mod.ts | 17 | ||||
-rw-r--r-- | ext/node/polyfills/path/posix.ts | 8 | ||||
-rw-r--r-- | ext/node/polyfills/path/separator.ts | 2 | ||||
-rw-r--r-- | ext/node/polyfills/path/win32.ts | 10 |
7 files changed, 26 insertions, 32 deletions
diff --git a/ext/node/polyfills/path/_util.ts b/ext/node/polyfills/path/_util.ts index ccc12abc9..1ba139924 100644 --- a/ext/node/polyfills/path/_util.ts +++ b/ext/node/polyfills/path/_util.ts @@ -2,7 +2,7 @@ // Ported from https://github.com/browserify/path-browserify/ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -import type { FormatInputPathObject } from "internal:deno_node/polyfills/path/_interface.ts"; +import type { FormatInputPathObject } from "internal:deno_node/path/_interface.ts"; import { CHAR_BACKWARD_SLASH, CHAR_DOT, @@ -11,8 +11,8 @@ import { CHAR_LOWERCASE_Z, CHAR_UPPERCASE_A, CHAR_UPPERCASE_Z, -} from "internal:deno_node/polyfills/path/_constants.ts"; -import { ERR_INVALID_ARG_TYPE } from "internal:deno_node/polyfills/internal/errors.ts"; +} from "internal:deno_node/path/_constants.ts"; +import { ERR_INVALID_ARG_TYPE } from "internal:deno_node/internal/errors.ts"; export function assertPath(path: string) { if (typeof path !== "string") { diff --git a/ext/node/polyfills/path/common.ts b/ext/node/polyfills/path/common.ts index e4efe7cc4..f8dad209b 100644 --- a/ext/node/polyfills/path/common.ts +++ b/ext/node/polyfills/path/common.ts @@ -1,7 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // This module is browser compatible. -import { SEP } from "internal:deno_node/polyfills/path/separator.ts"; +import { SEP } from "internal:deno_node/path/separator.ts"; /** Determines the common path from a set of paths, using an optional separator, * which defaults to the OS default separator. diff --git a/ext/node/polyfills/path/glob.ts b/ext/node/polyfills/path/glob.ts index c0da29b9f..00529eb3c 100644 --- a/ext/node/polyfills/path/glob.ts +++ b/ext/node/polyfills/path/glob.ts @@ -1,13 +1,10 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -import { isWindows, osType } from "internal:deno_node/polyfills/_util/os.ts"; -import { - SEP, - SEP_PATTERN, -} from "internal:deno_node/polyfills/path/separator.ts"; -import * as _win32 from "internal:deno_node/polyfills/path/win32.ts"; -import * as _posix from "internal:deno_node/polyfills/path/posix.ts"; -import type { OSType } from "internal:deno_node/polyfills/_util/os.ts"; +import { isWindows, osType } from "internal:deno_node/_util/os.ts"; +import { SEP, SEP_PATTERN } from "internal:deno_node/path/separator.ts"; +import * as _win32 from "internal:deno_node/path/win32.ts"; +import * as _posix from "internal:deno_node/path/posix.ts"; +import type { OSType } from "internal:deno_node/_util/os.ts"; const path = isWindows ? _win32 : _posix; const { join, normalize } = path; diff --git a/ext/node/polyfills/path/mod.ts b/ext/node/polyfills/path/mod.ts index 4b4de056b..eaeeeed74 100644 --- a/ext/node/polyfills/path/mod.ts +++ b/ext/node/polyfills/path/mod.ts @@ -2,9 +2,9 @@ // Ported mostly from https://github.com/browserify/path-browserify/ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -import { isWindows } from "internal:deno_node/polyfills/_util/os.ts"; -import _win32 from "internal:deno_node/polyfills/path/win32.ts"; -import _posix from "internal:deno_node/polyfills/path/posix.ts"; +import { isWindows } from "internal:deno_node/_util/os.ts"; +import _win32 from "internal:deno_node/path/win32.ts"; +import _posix from "internal:deno_node/path/posix.ts"; const path = isWindows ? _win32 : _posix; @@ -28,10 +28,7 @@ export const { toNamespacedPath, } = path; -export * from "internal:deno_node/polyfills/path/common.ts"; -export { - SEP, - SEP_PATTERN, -} from "internal:deno_node/polyfills/path/separator.ts"; -export * from "internal:deno_node/polyfills/path/_interface.ts"; -export * from "internal:deno_node/polyfills/path/glob.ts"; +export * from "internal:deno_node/path/common.ts"; +export { SEP, SEP_PATTERN } from "internal:deno_node/path/separator.ts"; +export * from "internal:deno_node/path/_interface.ts"; +export * from "internal:deno_node/path/glob.ts"; diff --git a/ext/node/polyfills/path/posix.ts b/ext/node/polyfills/path/posix.ts index 8ebf64629..f6ff13b76 100644 --- a/ext/node/polyfills/path/posix.ts +++ b/ext/node/polyfills/path/posix.ts @@ -5,12 +5,12 @@ import type { FormatInputPathObject, ParsedPath, -} from "internal:deno_node/polyfills/path/_interface.ts"; +} from "internal:deno_node/path/_interface.ts"; import { CHAR_DOT, CHAR_FORWARD_SLASH, -} from "internal:deno_node/polyfills/path/_constants.ts"; -import { ERR_INVALID_ARG_TYPE } from "internal:deno_node/polyfills/internal/errors.ts"; +} from "internal:deno_node/path/_constants.ts"; +import { ERR_INVALID_ARG_TYPE } from "internal:deno_node/internal/errors.ts"; import { _format, @@ -18,7 +18,7 @@ import { encodeWhitespace, isPosixPathSeparator, normalizeString, -} from "internal:deno_node/polyfills/path/_util.ts"; +} from "internal:deno_node/path/_util.ts"; export const sep = "/"; export const delimiter = ":"; diff --git a/ext/node/polyfills/path/separator.ts b/ext/node/polyfills/path/separator.ts index 2cfde31d0..cf089db71 100644 --- a/ext/node/polyfills/path/separator.ts +++ b/ext/node/polyfills/path/separator.ts @@ -1,6 +1,6 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. -import { isWindows } from "internal:deno_node/polyfills/_util/os.ts"; +import { isWindows } from "internal:deno_node/_util/os.ts"; export const SEP = isWindows ? "\\" : "/"; export const SEP_PATTERN = isWindows ? /[\\/]+/ : /\/+/; diff --git a/ext/node/polyfills/path/win32.ts b/ext/node/polyfills/path/win32.ts index 4b30e3430..4ba3ad0f1 100644 --- a/ext/node/polyfills/path/win32.ts +++ b/ext/node/polyfills/path/win32.ts @@ -5,14 +5,14 @@ import type { FormatInputPathObject, ParsedPath, -} from "internal:deno_node/polyfills/path/_interface.ts"; +} from "internal:deno_node/path/_interface.ts"; import { CHAR_BACKWARD_SLASH, CHAR_COLON, CHAR_DOT, CHAR_QUESTION_MARK, -} from "internal:deno_node/polyfills/path/_constants.ts"; -import { ERR_INVALID_ARG_TYPE } from "internal:deno_node/polyfills/internal/errors.ts"; +} from "internal:deno_node/path/_constants.ts"; +import { ERR_INVALID_ARG_TYPE } from "internal:deno_node/internal/errors.ts"; import { _format, @@ -21,8 +21,8 @@ import { isPathSeparator, isWindowsDeviceRoot, normalizeString, -} from "internal:deno_node/polyfills/path/_util.ts"; -import { assert } from "internal:deno_node/polyfills/_util/asserts.ts"; +} from "internal:deno_node/path/_util.ts"; +import { assert } from "internal:deno_node/_util/asserts.ts"; export const sep = "\\"; export const delimiter = ";"; |