@upleveled/preflight 9.0.2 → 9.0.4

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,32 @@
1
+ #!/usr/bin/env -S node --disable-warning=ExperimentalWarning
2
+
3
+ import { registerHooks, stripTypeScriptTypes } from 'node:module';
4
+
5
+ const tsRegex = /^file:.*(?<!\.d)\.m?ts$/;
6
+
7
+ // Intercept .ts / .mts files (skipping .d.ts files) and
8
+ // transpile to JS, returning ES module
9
+ registerHooks({
10
+ load(url, context, nextLoad) {
11
+ if (tsRegex.test(url)) {
12
+ return {
13
+ format: 'module',
14
+ source: stripTypeScriptTypes(
15
+ /** @type {import('node:module').ModuleSource} */ (
16
+ // eslint-disable-next-line @typescript-eslint/no-base-to-string -- ModuleSource returns useful information from .toString()
17
+ nextLoad(url).source
18
+ ).toString(),
19
+ {
20
+ mode: 'transform',
21
+ sourceUrl: url,
22
+ },
23
+ ),
24
+ };
25
+ }
26
+
27
+ return nextLoad(url, context);
28
+ },
29
+ });
30
+
31
+ // Path to entry point
32
+ await import('../src/index.ts');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@upleveled/preflight",
3
- "version": "9.0.2",
3
+ "version": "9.0.4",
4
4
  "repository": "upleveled/preflight",
5
5
  "license": "MIT",
6
6
  "author": "UpLeveled (https://github.com/upleveled)",
@@ -12,10 +12,9 @@
12
12
  "module": "./src/index.ts",
13
13
  "types": "./src/index.ts",
14
14
  "bin": {
15
- "preflight": "./bin/preflight.sh"
15
+ "preflight": "./bin/preflight.js"
16
16
  },
17
17
  "files": [
18
- "./bin/preflight.js",
19
18
  "src"
20
19
  ],
21
20
  "dependencies": {
package/bin/preflight.sh DELETED
@@ -1,42 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- set -o errexit
4
- set -o nounset
5
- set -o pipefail
6
-
7
- exec node --disable-warning=ExperimentalWarning --input-type=module --eval '
8
- import { registerHooks, stripTypeScriptTypes } from "node:module";
9
- import { dirname, resolve } from "node:path";
10
- import { argv } from "node:process";
11
- import { fileURLToPath, pathToFileURL } from "node:url";
12
-
13
- const tsRegex = /^file:.*(?<!\.d)\.m?ts$/;
14
-
15
- // Intercept .ts / .mts files (skipping .d.ts files) and
16
- // transpile to JS, returning ES module
17
- registerHooks({
18
- load(url, context, nextLoad) {
19
- if (tsRegex.test(url)) {
20
- return {
21
- format: "module",
22
- source: stripTypeScriptTypes(nextLoad(url).source.toString(), {
23
- mode: "transform",
24
- sourceUrl: url,
25
- }),
26
- };
27
- }
28
-
29
- return nextLoad(url, context);
30
- },
31
- });
32
-
33
- await import(
34
- pathToFileURL(
35
- resolve(
36
- dirname(argv[1]),
37
- // Path to entry point
38
- "../src/index.ts",
39
- ),
40
- ).href
41
- );
42
- ' "$0" "$@"