@0001-labs/idv1 1.0.1 → 1.0.2
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.
- package/bin/idv1.mjs +11 -2
- package/package.json +1 -1
package/bin/idv1.mjs
CHANGED
|
@@ -3,9 +3,18 @@ import { existsSync, readFileSync } from 'node:fs'
|
|
|
3
3
|
import { dirname, join, resolve } from 'node:path'
|
|
4
4
|
import { register } from 'node:module'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
const source = new URL('../src/', import.meta.url).href
|
|
7
|
+
register('data:text/javascript,' + encodeURIComponent(`import { readFileSync } from 'node:fs'
|
|
8
|
+
import { stripTypeScriptTypes } from 'node:module'
|
|
9
|
+
import { fileURLToPath } from 'node:url'
|
|
10
|
+
const source = ${JSON.stringify(source)}
|
|
11
|
+
export async function resolve(specifier, context, next) {
|
|
12
|
+
if (context.parentURL?.startsWith(source) && /^\\.\\.?\\//.test(specifier) && !/\\.[cm]?[jt]s$/.test(specifier)) return next(specifier + '.ts', context)
|
|
8
13
|
return next(specifier, context)
|
|
14
|
+
}
|
|
15
|
+
export async function load(url, context, next) {
|
|
16
|
+
if (url.startsWith(source) && url.endsWith('.ts')) return { format: 'module', source: stripTypeScriptTypes(readFileSync(fileURLToPath(url), 'utf8')), shortCircuit: true }
|
|
17
|
+
return next(url, context)
|
|
9
18
|
}`))
|
|
10
19
|
const { runArchitectureCommand } = await import('../src/architecture.ts')
|
|
11
20
|
|
package/package.json
CHANGED