foxglove/create-foxglove-extension

CLI broken, tests have started failing

amacneil opened this issue ยท 4 comments

~/src/fox (main)$ yarn test
yarn run v1.22.17
$ jest

 RUNS  src/create.test.ts
info No lockfile found.
 RUNS  src/create.test.ts
[2/4] ๐Ÿšš  Fetching packages...
[3/4] ๐Ÿ”—  Linking dependencies...
warning " > @foxglove/eslint-plugin@0.19.0" has unmet peer dependency "eslint-plugin-es@^4".
 RUNS  src/create.test.ts
[4/4] ๐Ÿ”จ  Building fresh packages...

success Saved lockfile.
success Saved 237 new dependencies.
<!-- adrian: snipped boring stuff -->
$ fox build --mode production
 RUNS  src/create.test.ts
Error: build failed: Errors:
ModuleBuildError: Module build failed (from ./node_modules/ts-loader/index.js):
Error: Debug Failure. False expression: Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.
    at Object.resolveTypeReferenceDirective (/private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/typescript/lib/typescript.js:42530:18)
    at /private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/ts-loader/dist/servicesHost.js:713:18
    at /private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/ts-loader/dist/servicesHost.js:128:141
    at Array.map (<anonymous>)
    at Object.resolveTypeReferenceDirectives (/private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/ts-loader/dist/servicesHost.js:128:124)
    at actualResolveTypeReferenceDirectiveNamesWorker (/private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/typescript/lib/typescript.js:116611:163)
    at resolveTypeReferenceDirectiveNamesWorker (/private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/typescript/lib/typescript.js:116911:26)
    at processTypeReferenceDirectives (/private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/typescript/lib/typescript.js:118393:31)
    at findSourceFileWorker (/private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/typescript/lib/typescript.js:118278:21)
    at findSourceFile (/private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/typescript/lib/typescript.js:118133:26)
    at /private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/@foxglove/fox/dist/build.js:59:35
    at /private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/webpack/lib/HookWebpackError.js:68:3
    at Hook.eval [as callAsync] (eval at create (/private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/tapable/lib/Hook.js:18:14)
    at Cache.shutdown (/private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/webpack/lib/Cache.js:150:23)
    at /private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/webpack/lib/Compiler.js:1127:15
    at Hook.eval [as callAsync] (eval at create (/private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
    at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/tapable/lib/Hook.js:18:14)
    at Compiler.close (/private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/webpack/lib/Compiler.js:1121:23)
    at /private/var/folders/ms/g4fyb1zs3cx5k4f3npp2qvfm0000gn/T/tmp-64444-kwi5Jw5OkPu5/extension-test/node_modules/@foxglove/fox/dist/build.js:51:22
 FAIL  src/create.test.ts (17.421 s)1.
  createCommand
    โœ• creates a skeleton extension package (17287 ms)

  โ— createCommand โ€บ creates a skeleton extension package

    thrown: "yarn failed with exit code 1"



      at src/create.test.ts:67:3
      at Object.<anonymous> (src/create.test.ts:66:1)

Test Suites: 1 failed, 1 total
Tests:       1 failed, 1 total
Snapshots:   0 total
Time:        17.439 s
Ran all test suites.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
~/src/fox (main)$

Appears that this was broken by Typescript 4.7 which was released 2 days ago (see #43).

Workaround for now is to change the typescript version to 4.6.x in your extension's package.json and run yarn:

$ cat package.json
{
  "name": "helloworld",
  "displayName": "helloworld",
  "description": "",
  "publisher": "unknown",
  "homepage": "",
  "version": "0.0.0",
  "license": "UNLICENSED",
  "main": "./dist/extension.js",
  "keywords": [],
  "scripts": {
    "build": "fox build",
    "foxglove:prepublish": "fox build --mode production",
    "lint:ci": "eslint --report-unused-disable-directives .",
    "lint": "eslint --report-unused-disable-directives --fix .",
    "local-install": "fox install",
    "package": "fox package",
    "pretest": "fox pretest"
  },
  "devDependencies": {
    "@foxglove/eslint-plugin": "0.19.0",
    "@foxglove/fox": "0.4.0",
    "@foxglove/studio": "1.12.1",
    "@types/react": "18.0.9",
    "@types/react-dom": "18.0.5",
    "@typescript-eslint/eslint-plugin": "5.26.0",
    "@typescript-eslint/parser": "5.26.0",
    "eslint": "8.16.0",
    "eslint-config-prettier": "8.5.0",
    "eslint-plugin-import": "2.26.0",
    "eslint-plugin-prettier": "4.0.0",
    "eslint-plugin-react": "7.30.0",
    "eslint-plugin-react-hooks": "4.5.0",
    "prettier": "2.6.2",
    "react": "18.1.0",
    "react-dom": "18.1.0",
    "typescript": "4.6.x"
  }
}
$ yarn
yarn install v1.22.17
[1/4] ๐Ÿ”  Resolving packages...
success Already up-to-date.
โœจ  Done in 0.08s.

Looks like the problem is that when we create an extension we just use the latest version of every package so that means we get typescript 4.7 in the generated package:

  "devDependencies": {
    "@foxglove/eslint-plugin": "0.19.0",
    "@foxglove/fox": "0.4.0",
    "@foxglove/studio": "1.12.1",
    "@types/react": "18.0.9",
    "@types/react-dom": "18.0.5",
    "@typescript-eslint/eslint-plugin": "5.26.0",
    "@typescript-eslint/parser": "5.26.0",
    "eslint": "8.16.0",
    "eslint-config-prettier": "8.5.0",
    "eslint-plugin-import": "2.26.0",
    "eslint-plugin-prettier": "4.0.0",
    "eslint-plugin-react": "7.30.0",
    "eslint-plugin-react-hooks": "4.5.0",
    "prettier": "2.6.2",
    "react": "18.1.0",
    "react-dom": "18.1.0",
    "typescript": "4.7.2"
  }

Keeping this open until we figure out exactly which packages aren't working with latest typescript.

Permanent fix in #63