Commit 5c25a82

Anton Medvedev <anton@medv.io>
2022-06-29 22:51:29
Add check for import without globals
1 parent 8d67731
.github/workflows/check.yml
@@ -3,6 +3,13 @@ name: Check
 on: [push, pull_request]
 
 jobs:
+  build:
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v3
+      - run: npm i
+      - run: npm run build:check
+
   coverage:
     runs-on: ubuntu-latest
     steps:
@@ -26,4 +33,4 @@ jobs:
       - uses: actions/checkout@v3
       - run: npm i
       - run: npm run build
-      - run: npm run tsd
+      - run: npm run test:types
src/cli.ts
@@ -19,13 +19,14 @@ import { createRequire } from 'node:module'
 import { tmpdir } from 'node:os'
 import { basename, dirname, extname, join, resolve } from 'node:path'
 import url from 'node:url'
-import './globals.js'
 import { updateArgv } from './goods.js'
 import { $, argv, chalk, fetch, ProcessOutput } from './index.js'
 import { startRepl } from './repl.js'
 import { randomId } from './util.js'
 
 await (async function main() {
+  const globals = './globals.js'
+  await import(globals)
   $.verbose = !argv.quiet
   if (typeof argv.shell === 'string') {
     $.shell = argv.shell
package.json
@@ -37,9 +37,10 @@
   "scripts": {
     "fmt": "prettier --write .",
     "fmt:check": "prettier --check .",
-    "build": "tsc",
-    "test": "tsc && PATH=$(env -i bash -c 'echo $PATH') node_modules/.bin/uvu test -i fixtures",
-    "tsd": "tsd",
+    "build": "tsc --project tsconfig.prod.json",
+    "build:check": "tsc",
+    "test": "npm run build && PATH=$(env -i bash -c 'echo $PATH') node_modules/.bin/uvu test -i fixtures",
+    "test:types": "tsd",
     "coverage": "c8 --check-coverage npm test -- -i package",
     "mutation": "stryker run"
   },
tsconfig.json
@@ -8,5 +8,6 @@
     "outDir": "./build",
     "declaration": true
   },
-  "include": ["./src/**/*"]
+  "include": ["./src/**/*"],
+  "exclude": ["./src/globals.ts"]
 }
tsconfig.prod.json
@@ -0,0 +1,4 @@
+{
+  "extends": "./tsconfig.json",
+  "exclude": []
+}