Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// An unsupported runtime must stop before loading a native binding.
const Module = require('node:module');
const original = Module._load;
Module._load = function (request, ...args) {
if (/binding[\\/]index\.(?:cjs|js)$/.test(request) || request.endsWith('.node')) {
throw new Error('NATIVE_BINDING_LOADED_BEFORE_VERSION_CHECK');
}
return original.call(this, request, ...args);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": "..",
"paths": {
"@value": [
"./src/config-compat.ts"
]
},
"useDefineForClassFields": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": "..",
"paths": {
"@value": [
"./src/config-explicit.ts"
]
},
"useDefineForClassFields": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": "..",
"paths": {
"@value": [
"./src/config-parent.ts"
]
},
"useDefineForClassFields": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": "..",
"paths": {
"@value": [
"./src/config-upstream.ts"
]
},
"useDefineForClassFields": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": "..",
"paths": {
"@value": [
"./src/config-worker-one.ts"
]
},
"useDefineForClassFields": false
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "../tsconfig.json",
"compilerOptions": {
"baseUrl": "..",
"paths": {
"@value": [
"./src/config-worker-two.ts"
]
},
"useDefineForClassFields": true
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
enum Failure { Value = 'dependency failure' }
export function fail() {
throw new Error(Failure.Value);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export enum Kind { Value = 'esm dependency' }
export const kind: Kind = Kind.Value;
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "fixture-ts-import",
"type": "module",
"exports": {
".": "./index.ts",
"./error": "./error.ts"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
enum Kind { Value = 'cjs dependency' }
module.exports = Kind.Value;
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"name": "fixture-ts-require",
"main": "./index.cts"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "command-script-import",
"version": "1.0.0",
"private": true,
"type": "module",
"engines": {
"node": "22.18.0"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { spawnSync } from 'node:child_process';
import { createRequire } from 'node:module';
import { pathToFileURL } from 'node:url';

const register = createRequire(import.meta.url).resolve('vite-plus/register');
const preload = process.argv[2] === 'path' ? register : pathToFileURL(register).href;
console.log('preload:', preload.replaceAll('\\', '/'));
const child = spawnSync(process.execPath, ['--import', preload, './src/name #%.ts'], {
stdio: 'inherit',
timeout: 30000,
});
if (child.error) throw child.error;
process.exitCode = child.status ?? 1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { createRequire } from 'node:module';
import { pathToFileURL } from 'node:url';

const require = createRequire(import.meta.url);
const register = require.resolve('vite-plus/register');
console.log(JSON.stringify({
node: process.versions.node,
requireExport: register.replaceAll('\\', '/'),
importExport: import.meta.resolve('vite-plus/register'),
sameExport: import.meta.resolve('vite-plus/register') === pathToFileURL(register).href,
}, null, 2));
try {
console.log('tsx:', require.resolve('tsx'));
} catch (error) {
console.log('tsx:', error.code);
}

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# script_import_native_watch

A public preload preserves Node.js native watch mode.

## `node verify-watch.mjs`

```
native node --watch reloads an imported TypeScript dependency
```
Loading
Loading