mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
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.
This commit is contained in:
parent
01028fcdf4
commit
b40086fd7d
219 changed files with 1205 additions and 1273 deletions
|
@ -20,13 +20,13 @@
|
|||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
||||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
import { Buffer } from "internal:deno_node/polyfills/buffer.ts";
|
||||
import { EventEmitter } from "internal:deno_node/polyfills/events.ts";
|
||||
import { lookup as defaultLookup } from "internal:deno_node/polyfills/dns.ts";
|
||||
import { Buffer } from "internal:deno_node/buffer.ts";
|
||||
import { EventEmitter } from "internal:deno_node/events.ts";
|
||||
import { lookup as defaultLookup } from "internal:deno_node/dns.ts";
|
||||
import type {
|
||||
ErrnoException,
|
||||
NodeSystemErrorCtx,
|
||||
} from "internal:deno_node/polyfills/internal/errors.ts";
|
||||
} from "internal:deno_node/internal/errors.ts";
|
||||
import {
|
||||
ERR_BUFFER_OUT_OF_BOUNDS,
|
||||
ERR_INVALID_ARG_TYPE,
|
||||
|
@ -40,34 +40,28 @@ import {
|
|||
ERR_SOCKET_DGRAM_NOT_RUNNING,
|
||||
errnoException,
|
||||
exceptionWithHostPort,
|
||||
} from "internal:deno_node/polyfills/internal/errors.ts";
|
||||
import type { Abortable } from "internal:deno_node/polyfills/_events.d.ts";
|
||||
import {
|
||||
kStateSymbol,
|
||||
newHandle,
|
||||
} from "internal:deno_node/polyfills/internal/dgram.ts";
|
||||
import type { SocketType } from "internal:deno_node/polyfills/internal/dgram.ts";
|
||||
} from "internal:deno_node/internal/errors.ts";
|
||||
import type { Abortable } from "internal:deno_node/_events.d.ts";
|
||||
import { kStateSymbol, newHandle } from "internal:deno_node/internal/dgram.ts";
|
||||
import type { SocketType } from "internal:deno_node/internal/dgram.ts";
|
||||
import {
|
||||
asyncIdSymbol,
|
||||
defaultTriggerAsyncIdScope,
|
||||
ownerSymbol,
|
||||
} from "internal:deno_node/polyfills/internal/async_hooks.ts";
|
||||
import {
|
||||
SendWrap,
|
||||
UDP,
|
||||
} from "internal:deno_node/polyfills/internal_binding/udp_wrap.ts";
|
||||
} from "internal:deno_node/internal/async_hooks.ts";
|
||||
import { SendWrap, UDP } from "internal:deno_node/internal_binding/udp_wrap.ts";
|
||||
import {
|
||||
isInt32,
|
||||
validateAbortSignal,
|
||||
validateNumber,
|
||||
validatePort,
|
||||
validateString,
|
||||
} from "internal:deno_node/polyfills/internal/validators.mjs";
|
||||
import { guessHandleType } from "internal:deno_node/polyfills/internal_binding/util.ts";
|
||||
import { os } from "internal:deno_node/polyfills/internal_binding/constants.ts";
|
||||
import { nextTick } from "internal:deno_node/polyfills/process.ts";
|
||||
import { channel } from "internal:deno_node/polyfills/diagnostics_channel.ts";
|
||||
import { isArrayBufferView } from "internal:deno_node/polyfills/internal/util/types.ts";
|
||||
} from "internal:deno_node/internal/validators.mjs";
|
||||
import { guessHandleType } from "internal:deno_node/internal_binding/util.ts";
|
||||
import { os } from "internal:deno_node/internal_binding/constants.ts";
|
||||
import { nextTick } from "internal:deno_node/process.ts";
|
||||
import { channel } from "internal:deno_node/diagnostics_channel.ts";
|
||||
import { isArrayBufferView } from "internal:deno_node/internal/util/types.ts";
|
||||
|
||||
const { UV_UDP_REUSEADDR, UV_UDP_IPV6ONLY } = os;
|
||||
|
||||
|
@ -247,8 +241,8 @@ export class Socket extends EventEmitter {
|
|||
* `EADDRINUSE` error will occur:
|
||||
*
|
||||
* ```js
|
||||
* import cluster from "internal:deno_node/polyfills/cluster";
|
||||
* import dgram from "internal:deno_node/polyfills/dgram";
|
||||
* import cluster from "internal:deno_node/cluster";
|
||||
* import dgram from "internal:deno_node/dgram";
|
||||
*
|
||||
* if (cluster.isPrimary) {
|
||||
* cluster.fork(); // Works ok.
|
||||
|
@ -349,7 +343,7 @@ export class Socket extends EventEmitter {
|
|||
* Example of a UDP server listening on port 41234:
|
||||
*
|
||||
* ```js
|
||||
* import dgram from "internal:deno_node/polyfills/dgram";
|
||||
* import dgram from "internal:deno_node/dgram";
|
||||
*
|
||||
* const server = dgram.createSocket('udp4');
|
||||
*
|
||||
|
@ -798,8 +792,8 @@ export class Socket extends EventEmitter {
|
|||
* Example of sending a UDP packet to a port on `localhost`;
|
||||
*
|
||||
* ```js
|
||||
* import dgram from "internal:deno_node/polyfills/dgram";
|
||||
* import { Buffer } from "internal:deno_node/polyfills/buffer";
|
||||
* import dgram from "internal:deno_node/dgram";
|
||||
* import { Buffer } from "internal:deno_node/buffer";
|
||||
*
|
||||
* const message = Buffer.from('Some bytes');
|
||||
* const client = dgram.createSocket('udp4');
|
||||
|
@ -812,8 +806,8 @@ export class Socket extends EventEmitter {
|
|||
* `127.0.0.1`;
|
||||
*
|
||||
* ```js
|
||||
* import dgram from "internal:deno_node/polyfills/dgram";
|
||||
* import { Buffer } from "internal:deno_node/polyfills/buffer";
|
||||
* import dgram from "internal:deno_node/dgram";
|
||||
* import { Buffer } from "internal:deno_node/buffer";
|
||||
*
|
||||
* const buf1 = Buffer.from('Some ');
|
||||
* const buf2 = Buffer.from('bytes');
|
||||
|
@ -832,8 +826,8 @@ export class Socket extends EventEmitter {
|
|||
* `localhost`:
|
||||
*
|
||||
* ```js
|
||||
* import dgram from "internal:deno_node/polyfills/dgram";
|
||||
* import { Buffer } from "internal:deno_node/polyfills/buffer";
|
||||
* import dgram from "internal:deno_node/dgram";
|
||||
* import { Buffer } from "internal:deno_node/buffer";
|
||||
*
|
||||
* const message = Buffer.from('Some bytes');
|
||||
* const client = dgram.createSocket('udp4');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue