@hirarijs/loader 1.0.5 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,257 @@
1
+ // src/config.ts
2
+ import fs from "fs";
3
+ import path2 from "path";
4
+ var DEFAULT_CONFIG = {
5
+ format: "cjs",
6
+ plugins: ["@hirarijs/loader-ts", "@hirarijs/loader-tsx", "@hirarijs/loader-vue"]
7
+ };
8
+ function loadHirariConfig(cwd = process.cwd()) {
9
+ const configPath = path2.join(cwd, "hirari.json");
10
+ if (!fs.existsSync(configPath)) {
11
+ return { ...DEFAULT_CONFIG };
12
+ }
13
+ const raw = fs.readFileSync(configPath, "utf8");
14
+ let parsed;
15
+ try {
16
+ parsed = JSON.parse(raw);
17
+ } catch (error) {
18
+ throw new Error(`Failed to parse hirari.json: ${error.message}`);
19
+ }
20
+ const loaderConfig = parsed.loader || {};
21
+ return {
22
+ ...DEFAULT_CONFIG,
23
+ ...loaderConfig,
24
+ plugins: loaderConfig.plugins?.length ? loaderConfig.plugins : DEFAULT_CONFIG.plugins
25
+ };
26
+ }
27
+ function getFormat(config) {
28
+ return config.format === "esm" ? "esm" : "cjs";
29
+ }
30
+
31
+ // src/constants.ts
32
+ var IMPORT_META_URL_VARIABLE = "__hirari_loader_import_meta_url__";
33
+
34
+ // src/plugin-manager.ts
35
+ import { spawnSync } from "child_process";
36
+ import fs2 from "fs";
37
+ import path3 from "path";
38
+ import { createRequire } from "module";
39
+ var PACKAGE_MANAGERS = [
40
+ { lock: "pnpm-lock.yaml", command: "pnpm", args: ["add"] },
41
+ { lock: "yarn.lock", command: "yarn", args: ["add"] },
42
+ { lock: "package-lock.json", command: "npm", args: ["install"] },
43
+ { lock: "npm-shrinkwrap.json", command: "npm", args: ["install"] }
44
+ ];
45
+ function detectPackageManager(cwd) {
46
+ for (const pm of PACKAGE_MANAGERS) {
47
+ if (fs2.existsSync(path3.join(cwd, pm.lock))) return pm;
48
+ }
49
+ return { command: "npm", args: ["install"] };
50
+ }
51
+ function tryRequire(moduleId, cwd) {
52
+ const req = createRequire(path3.join(cwd, "noop.js"));
53
+ const loaded = req(moduleId);
54
+ return loaded && (loaded.default || loaded);
55
+ }
56
+ function install(pkg, cwd) {
57
+ const pm = detectPackageManager(cwd);
58
+ const result = spawnSync(pm.command, [...pm.args, pkg], {
59
+ cwd,
60
+ stdio: "inherit",
61
+ env: process.env
62
+ });
63
+ if (result.error) {
64
+ throw result.error;
65
+ }
66
+ if (result.status !== 0) {
67
+ throw new Error(`${pm.command} ${pm.args.join(" ")} ${pkg} failed`);
68
+ }
69
+ }
70
+ function resolvePlugins(config, cwd) {
71
+ const plugins = [];
72
+ for (const pluginName of config.plugins || []) {
73
+ let loaded = null;
74
+ try {
75
+ loaded = tryRequire(pluginName, cwd);
76
+ } catch (error) {
77
+ if (config.autoInstall) {
78
+ console.log(`[hirari-loader] installing missing plugin ${pluginName}`);
79
+ install(pluginName, cwd);
80
+ loaded = tryRequire(pluginName, cwd);
81
+ } else {
82
+ throw new Error(
83
+ `Plugin "${pluginName}" not found. Enable autoInstall or install manually.`
84
+ );
85
+ }
86
+ }
87
+ if (!loaded) continue;
88
+ plugins.push({
89
+ plugin: loaded,
90
+ options: config.pluginOptions?.[pluginName]
91
+ });
92
+ if (config.debug) {
93
+ console.log(`[hirari-loader] loaded plugin ${pluginName}`);
94
+ }
95
+ }
96
+ return plugins;
97
+ }
98
+
99
+ // src/runtime.ts
100
+ import fs3 from "fs";
101
+ import module from "module";
102
+ import { fileURLToPath, pathToFileURL } from "url";
103
+ import { addHook } from "pirates";
104
+ import * as sourceMapSupport from "source-map-support";
105
+ var map = {};
106
+ var EXTENSION_CANDIDATES = [
107
+ ".ts",
108
+ ".mts",
109
+ ".cts",
110
+ ".tsx",
111
+ ".jsx",
112
+ ".vue",
113
+ ".js",
114
+ ".mjs",
115
+ ".cjs"
116
+ ];
117
+ function installSourceMaps() {
118
+ sourceMapSupport.install({
119
+ handleUncaughtExceptions: false,
120
+ environment: "node",
121
+ retrieveSourceMap(file) {
122
+ if (map[file]) {
123
+ return { url: file, map: map[file] };
124
+ }
125
+ return null;
126
+ }
127
+ });
128
+ }
129
+ var toNodeLoaderFormat = (format) => format === "esm" ? "module" : "commonjs";
130
+ function createRuntime(cwd = process.cwd()) {
131
+ const loaderConfig = loadHirariConfig(cwd);
132
+ const resolvedPlugins = resolvePlugins(loaderConfig, cwd);
133
+ installSourceMaps();
134
+ return {
135
+ cwd,
136
+ loaderConfig,
137
+ resolvedPlugins,
138
+ format: getFormat(loaderConfig)
139
+ };
140
+ }
141
+ function pickPlugin(filename, plugins) {
142
+ return plugins.find(({ plugin }) => plugin.match(filename));
143
+ }
144
+ function applyPlugin(code, filename, runtime) {
145
+ const match = pickPlugin(filename, runtime.resolvedPlugins);
146
+ if (!match) {
147
+ if (runtime.loaderConfig.debug) {
148
+ console.log(`[hirari-loader] no plugin matched ${filename}`);
149
+ }
150
+ return { code };
151
+ }
152
+ const ctx = {
153
+ format: runtime.format,
154
+ loaderConfig: runtime.loaderConfig,
155
+ pluginOptions: match.options
156
+ };
157
+ const result = match.plugin.transform(code, filename, ctx);
158
+ if (runtime.loaderConfig.debug) {
159
+ console.log(`[hirari-loader][${match.plugin.name}] compiled ${filename}`);
160
+ console.log(result.code);
161
+ }
162
+ if (result.map) {
163
+ map[filename] = result.map;
164
+ }
165
+ return result;
166
+ }
167
+ function collectExtensions(plugins) {
168
+ const set = /* @__PURE__ */ new Set();
169
+ for (const { plugin } of plugins) {
170
+ plugin.extensions.forEach((ext) => set.add(ext));
171
+ }
172
+ return Array.from(set);
173
+ }
174
+ function registerRequireHooks(runtime) {
175
+ const extensions = collectExtensions(runtime.resolvedPlugins);
176
+ const compile = (code, filename) => {
177
+ const result = applyPlugin(code, filename, runtime);
178
+ const banner = `const ${IMPORT_META_URL_VARIABLE} = require('url').pathToFileURL(__filename).href;`;
179
+ if (!result.code.includes(IMPORT_META_URL_VARIABLE)) {
180
+ return `${banner}${result.code}`;
181
+ }
182
+ return result.code;
183
+ };
184
+ const revert = addHook(compile, {
185
+ exts: extensions,
186
+ ignoreNodeModules: runtime.loaderConfig.hookIgnoreNodeModules ?? true
187
+ });
188
+ const extensionsObj = module.Module._extensions;
189
+ const jsHandler = extensionsObj[".js"];
190
+ extensionsObj[".js"] = function(mod, filename) {
191
+ try {
192
+ return jsHandler.call(this, mod, filename);
193
+ } catch (error) {
194
+ if (error && error.code === "ERR_REQUIRE_ESM") {
195
+ const src = fs3.readFileSync(filename, "utf8");
196
+ const result = applyPlugin(src, filename, runtime);
197
+ mod._compile(result.code, filename);
198
+ return;
199
+ }
200
+ throw error;
201
+ }
202
+ };
203
+ return () => {
204
+ revert();
205
+ extensionsObj[".js"] = jsHandler;
206
+ };
207
+ }
208
+ async function loaderResolve(specifier, context, next) {
209
+ if (!path.extname(specifier) && (specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/") || specifier.startsWith("file:")) && !specifier.startsWith("node:")) {
210
+ const parent = (context && context.parentURL && context.parentURL.startsWith("file:")) ?? false ? fileURLToPath(context.parentURL) : process.cwd();
211
+ const basePath = specifier.startsWith("file:") ? fileURLToPath(specifier) : specifier.startsWith("/") ? specifier : path.resolve(path.dirname(parent), specifier);
212
+ for (const ext of EXTENSION_CANDIDATES) {
213
+ const candidate = basePath + ext;
214
+ if (fs3.existsSync(candidate) && fs3.statSync(candidate).isFile()) {
215
+ const url = pathToFileURL(candidate).href;
216
+ return { url };
217
+ }
218
+ }
219
+ }
220
+ if (next) return next(specifier, context);
221
+ return { url: specifier };
222
+ }
223
+ async function loaderLoad(url, context, next, runtime) {
224
+ const { format: expectedFormat } = runtime;
225
+ if (url.startsWith("file://")) {
226
+ const filename = fileURLToPath(url);
227
+ const match = pickPlugin(filename, runtime.resolvedPlugins);
228
+ if (runtime.loaderConfig.debug) {
229
+ console.log(`[hirari-loader] load hook url=${url} match=${!!match}`);
230
+ }
231
+ if (match) {
232
+ const source = fs3.readFileSync(filename, "utf8");
233
+ const result = applyPlugin(source, filename, runtime);
234
+ return {
235
+ format: toNodeLoaderFormat(result.format || expectedFormat),
236
+ source: result.code,
237
+ shortCircuit: true
238
+ };
239
+ }
240
+ }
241
+ if (!next) {
242
+ throw new Error("No default loader available for " + url);
243
+ }
244
+ const forwarded = await next(url, context);
245
+ if (forwarded) return forwarded;
246
+ throw new Error("Loader did not return a result for " + url);
247
+ }
248
+
249
+ export {
250
+ loadHirariConfig,
251
+ IMPORT_META_URL_VARIABLE,
252
+ resolvePlugins,
253
+ createRuntime,
254
+ registerRequireHooks,
255
+ loaderResolve,
256
+ loaderLoad
257
+ };
@@ -0,0 +1,15 @@
1
+ import {
2
+ createRuntime,
3
+ registerRequireHooks
4
+ } from "./chunk-GKPZ4KUK.js";
5
+
6
+ // src/register.ts
7
+ function register(cwd = process.cwd()) {
8
+ const runtime = createRuntime(cwd);
9
+ const unregister = registerRequireHooks(runtime);
10
+ return { unregister };
11
+ }
12
+
13
+ export {
14
+ register
15
+ };
@@ -0,0 +1,15 @@
1
+ import {
2
+ createRuntime,
3
+ registerRequireHooks
4
+ } from "./chunk-YKEMNYPA.js";
5
+
6
+ // src/register.ts
7
+ function register(cwd = process.cwd()) {
8
+ const runtime = createRuntime(cwd);
9
+ const unregister = registerRequireHooks(runtime);
10
+ return { unregister };
11
+ }
12
+
13
+ export {
14
+ register
15
+ };
@@ -0,0 +1,15 @@
1
+ import {
2
+ createRuntime,
3
+ registerRequireHooks
4
+ } from "./chunk-4XWHBXWU.js";
5
+
6
+ // src/register.ts
7
+ function register(cwd = process.cwd()) {
8
+ const runtime = createRuntime(cwd);
9
+ const unregister = registerRequireHooks(runtime);
10
+ return { unregister };
11
+ }
12
+
13
+ export {
14
+ register
15
+ };
@@ -0,0 +1,281 @@
1
+ // src/config.ts
2
+ import fs from "fs";
3
+ import path from "path";
4
+ var DEFAULT_CONFIG = {
5
+ format: "cjs",
6
+ plugins: ["@hirarijs/loader-ts", "@hirarijs/loader-tsx", "@hirarijs/loader-vue"]
7
+ };
8
+ function loadHirariConfig(cwd = process.cwd()) {
9
+ const configPath = path.join(cwd, "hirari.json");
10
+ if (!fs.existsSync(configPath)) {
11
+ return { ...DEFAULT_CONFIG };
12
+ }
13
+ const raw = fs.readFileSync(configPath, "utf8");
14
+ let parsed;
15
+ try {
16
+ parsed = JSON.parse(raw);
17
+ } catch (error) {
18
+ throw new Error(`Failed to parse hirari.json: ${error.message}`);
19
+ }
20
+ const loaderConfig = parsed.loader || {};
21
+ return {
22
+ ...DEFAULT_CONFIG,
23
+ ...loaderConfig,
24
+ plugins: loaderConfig.plugins?.length ? loaderConfig.plugins : DEFAULT_CONFIG.plugins
25
+ };
26
+ }
27
+ function getFormat(config) {
28
+ return config.format === "esm" ? "esm" : "cjs";
29
+ }
30
+
31
+ // src/constants.ts
32
+ var IMPORT_META_URL_VARIABLE = "__hirari_loader_import_meta_url__";
33
+
34
+ // src/plugin-manager.ts
35
+ import { spawnSync } from "child_process";
36
+ import fs2 from "fs";
37
+ import path2 from "path";
38
+ import { createRequire } from "module";
39
+ var PACKAGE_MANAGERS = [
40
+ { lock: "pnpm-lock.yaml", command: "pnpm", args: ["add"] },
41
+ { lock: "yarn.lock", command: "yarn", args: ["add"] },
42
+ { lock: "package-lock.json", command: "npm", args: ["install"] },
43
+ { lock: "npm-shrinkwrap.json", command: "npm", args: ["install"] }
44
+ ];
45
+ function detectPackageManager(cwd) {
46
+ for (const pm of PACKAGE_MANAGERS) {
47
+ if (fs2.existsSync(path2.join(cwd, pm.lock))) return pm;
48
+ }
49
+ return { command: "npm", args: ["install"] };
50
+ }
51
+ function tryRequire(moduleId, cwd) {
52
+ const req = createRequire(path2.join(cwd, "noop.js"));
53
+ const loaded = req(moduleId);
54
+ return loaded && (loaded.default || loaded);
55
+ }
56
+ function install(pkg, cwd) {
57
+ const pm = detectPackageManager(cwd);
58
+ const result = spawnSync(pm.command, [...pm.args, pkg], {
59
+ cwd,
60
+ stdio: "inherit",
61
+ env: process.env
62
+ });
63
+ if (result.error) {
64
+ throw result.error;
65
+ }
66
+ if (result.status !== 0) {
67
+ throw new Error(`${pm.command} ${pm.args.join(" ")} ${pkg} failed`);
68
+ }
69
+ }
70
+ function resolvePlugins(config, cwd) {
71
+ const plugins = [];
72
+ for (const pluginName of config.plugins || []) {
73
+ let loaded = null;
74
+ try {
75
+ loaded = tryRequire(pluginName, cwd);
76
+ } catch (error) {
77
+ if (config.autoInstall) {
78
+ console.log(`[hirari-loader] installing missing plugin ${pluginName}`);
79
+ install(pluginName, cwd);
80
+ loaded = tryRequire(pluginName, cwd);
81
+ } else {
82
+ throw new Error(
83
+ `Plugin "${pluginName}" not found. Enable autoInstall or install manually.`
84
+ );
85
+ }
86
+ }
87
+ if (!loaded) continue;
88
+ plugins.push({
89
+ plugin: loaded,
90
+ options: config.pluginOptions?.[pluginName]
91
+ });
92
+ if (config.debug) {
93
+ console.log(`[hirari-loader] loaded plugin ${pluginName}`);
94
+ }
95
+ }
96
+ return plugins;
97
+ }
98
+
99
+ // src/runtime.ts
100
+ import fs3 from "fs";
101
+ import module from "module";
102
+ import path3 from "path";
103
+ import { fileURLToPath, pathToFileURL } from "url";
104
+ import { addHook } from "pirates";
105
+ import * as sourceMapSupport from "source-map-support";
106
+ var map = {};
107
+ var EXTENSION_CANDIDATES = [
108
+ ".ts",
109
+ ".mts",
110
+ ".cts",
111
+ ".tsx",
112
+ ".jsx",
113
+ ".vue",
114
+ ".js",
115
+ ".mjs",
116
+ ".cjs"
117
+ ];
118
+ function installSourceMaps() {
119
+ sourceMapSupport.install({
120
+ handleUncaughtExceptions: false,
121
+ environment: "node",
122
+ retrieveSourceMap(file) {
123
+ if (map[file]) {
124
+ return { url: file, map: map[file] };
125
+ }
126
+ return null;
127
+ }
128
+ });
129
+ }
130
+ var toNodeLoaderFormat = (format) => format === "esm" ? "module" : "commonjs";
131
+ function createRuntime(cwd = process.cwd()) {
132
+ const loaderConfig = loadHirariConfig(cwd);
133
+ const resolvedPlugins = resolvePlugins(loaderConfig, cwd);
134
+ installSourceMaps();
135
+ return {
136
+ cwd,
137
+ loaderConfig,
138
+ resolvedPlugins,
139
+ format: getFormat(loaderConfig)
140
+ };
141
+ }
142
+ function pickPlugin(filename, plugins) {
143
+ return plugins.find(({ plugin }) => plugin.match(filename));
144
+ }
145
+ function applyPlugin(code, filename, runtime) {
146
+ const match = pickPlugin(filename, runtime.resolvedPlugins);
147
+ if (!match) {
148
+ if (runtime.loaderConfig.debug) {
149
+ console.log(`[hirari-loader] no plugin matched ${filename}`);
150
+ }
151
+ return { code };
152
+ }
153
+ const ctx = {
154
+ format: runtime.format,
155
+ loaderConfig: runtime.loaderConfig,
156
+ pluginOptions: match.options
157
+ };
158
+ const result = match.plugin.transform(code, filename, ctx);
159
+ if (runtime.loaderConfig.debug) {
160
+ console.log(`[hirari-loader][${match.plugin.name}] compiled ${filename}`);
161
+ }
162
+ if (result.map) {
163
+ map[filename] = result.map;
164
+ }
165
+ return result;
166
+ }
167
+ function collectExtensions(plugins) {
168
+ const set = /* @__PURE__ */ new Set();
169
+ for (const { plugin } of plugins) {
170
+ plugin.extensions.forEach((ext) => set.add(ext));
171
+ }
172
+ return Array.from(set);
173
+ }
174
+ function registerRequireHooks(runtime) {
175
+ const extensions = collectExtensions(runtime.resolvedPlugins);
176
+ const compile = (code, filename) => {
177
+ const result = applyPlugin(code, filename, runtime);
178
+ const banner = `const ${IMPORT_META_URL_VARIABLE} = require('url').pathToFileURL(__filename).href;`;
179
+ if (!result.code.includes(IMPORT_META_URL_VARIABLE)) {
180
+ return `${banner}${result.code}`;
181
+ }
182
+ return result.code;
183
+ };
184
+ const revert = addHook(compile, {
185
+ exts: extensions,
186
+ ignoreNodeModules: runtime.loaderConfig.hookIgnoreNodeModules ?? true
187
+ });
188
+ const extensionsObj = module.Module._extensions;
189
+ const jsHandler = extensionsObj[".js"];
190
+ extensionsObj[".js"] = function(mod, filename) {
191
+ try {
192
+ return jsHandler.call(this, mod, filename);
193
+ } catch (error) {
194
+ if (error && error.code === "ERR_REQUIRE_ESM") {
195
+ const src = fs3.readFileSync(filename, "utf8");
196
+ const result = applyPlugin(src, filename, runtime);
197
+ mod._compile(result.code, filename);
198
+ return;
199
+ }
200
+ throw error;
201
+ }
202
+ };
203
+ return () => {
204
+ revert();
205
+ extensionsObj[".js"] = jsHandler;
206
+ };
207
+ }
208
+ async function loaderResolve(specifier, context, next, runtime) {
209
+ const parentUrl = context && context.parentURL;
210
+ const baseDir = parentUrl && typeof parentUrl === "string" && parentUrl.startsWith("file:") ? path3.dirname(fileURLToPath(parentUrl)) : process.cwd();
211
+ const tryResolve = (basePath, note) => {
212
+ for (const ext2 of EXTENSION_CANDIDATES) {
213
+ const candidate = basePath + ext2;
214
+ if (fs3.existsSync(candidate) && fs3.statSync(candidate).isFile()) {
215
+ const url = pathToFileURL(candidate).href;
216
+ if (runtime.loaderConfig.debug) {
217
+ console.log(`[hirari-loader] resolve ${note} ${specifier} -> ${url}`);
218
+ }
219
+ return { url, shortCircuit: true };
220
+ }
221
+ const indexCandidate = path3.join(basePath, "index" + ext2);
222
+ if (fs3.existsSync(indexCandidate) && fs3.statSync(indexCandidate).isFile()) {
223
+ const url = pathToFileURL(indexCandidate).href;
224
+ if (runtime.loaderConfig.debug) {
225
+ console.log(`[hirari-loader] resolve ${note} ${specifier} -> ${url}`);
226
+ }
227
+ return { url, shortCircuit: true };
228
+ }
229
+ }
230
+ return null;
231
+ };
232
+ if (!path3.extname(specifier) && (specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/") || specifier.startsWith("file:")) && !specifier.startsWith("node:")) {
233
+ const basePath = specifier.startsWith("file:") ? fileURLToPath(specifier) : specifier.startsWith("/") ? specifier : path3.resolve(baseDir, specifier);
234
+ const res = tryResolve(basePath, "extless");
235
+ if (res) return res;
236
+ }
237
+ const ext = path3.extname(specifier);
238
+ if ((ext === ".js" || ext === ".mjs" || ext === ".cjs") && (specifier.startsWith("./") || specifier.startsWith("../") || specifier.startsWith("/") || specifier.startsWith("file:"))) {
239
+ const withoutExt = specifier.slice(0, -ext.length);
240
+ const basePath = specifier.startsWith("file:") ? fileURLToPath(withoutExt) : specifier.startsWith("/") ? withoutExt : path3.resolve(baseDir, withoutExt);
241
+ const res = tryResolve(basePath, "fallback-js");
242
+ if (res) return res;
243
+ }
244
+ if (next) return next(specifier, context);
245
+ return { url: specifier, shortCircuit: true };
246
+ }
247
+ async function loaderLoad(url, context, next, runtime) {
248
+ const { format: expectedFormat } = runtime;
249
+ if (url.startsWith("file://")) {
250
+ const filename = fileURLToPath(url);
251
+ const match = pickPlugin(filename, runtime.resolvedPlugins);
252
+ if (runtime.loaderConfig.debug) {
253
+ console.log(`[hirari-loader] load hook url=${url} match=${!!match}`);
254
+ }
255
+ if (match) {
256
+ const source = fs3.readFileSync(filename, "utf8");
257
+ const result = applyPlugin(source, filename, runtime);
258
+ return {
259
+ format: toNodeLoaderFormat(result.format || expectedFormat),
260
+ source: result.code,
261
+ shortCircuit: true
262
+ };
263
+ }
264
+ }
265
+ if (!next) {
266
+ throw new Error("No default loader available for " + url);
267
+ }
268
+ const forwarded = await next(url, context);
269
+ if (forwarded) return forwarded;
270
+ throw new Error("Loader did not return a result for " + url);
271
+ }
272
+
273
+ export {
274
+ loadHirariConfig,
275
+ IMPORT_META_URL_VARIABLE,
276
+ resolvePlugins,
277
+ createRuntime,
278
+ registerRequireHooks,
279
+ loaderResolve,
280
+ loaderLoad
281
+ };
@@ -0,0 +1,15 @@
1
+ import {
2
+ createRuntime,
3
+ registerRequireHooks
4
+ } from "./chunk-YOQCZ6TV.js";
5
+
6
+ // src/register.ts
7
+ function register(cwd = process.cwd()) {
8
+ const runtime = createRuntime(cwd);
9
+ const unregister = registerRequireHooks(runtime);
10
+ return { unregister };
11
+ }
12
+
13
+ export {
14
+ register
15
+ };
@@ -0,0 +1,15 @@
1
+ import {
2
+ createRuntime,
3
+ registerRequireHooks
4
+ } from "./chunk-UF3Z4PWI.js";
5
+
6
+ // src/register.ts
7
+ function register(cwd = process.cwd()) {
8
+ const runtime = createRuntime(cwd);
9
+ const unregister = registerRequireHooks(runtime);
10
+ return { unregister };
11
+ }
12
+
13
+ export {
14
+ register
15
+ };