Fork me on GitHub
#shadow-cljs
<
2024-01-11
>
Adam Helins00:01:21

I have no idea how I got myself into this but I'm not able to compile browser tests in release mode anymore. Seems like something is happening twice? I tried deleting the builds cache.

[:test/browser] Compiling ...
Closure compilation failed with 1 errors
--- cljs_test_display/core.cljs:411
@define cljs_test_display.core.root_node_id has already been set at cljs_test_display/core.cljs:5:23.

thheller05:01:30

you sure this worked before?

Adam Helins10:01:34

I'm think it worked at some point but I'm in the processing of doing a lot of repo / config refactoring, there is some reasonable doubt attached. If it did break indeed, tt's very likely something I did, not a bug :thinking_face:

thheller10:01:36

I don't see how this could have ever worked

thheller10:01:51

well maybe the closure compiler treated it as a warning before and now an error

thheller10:01:17

thats pretty much the only guess I have. closure defines are not supposed to be reassigned, so this mistake has been there forever

thheller10:01:34

I can't say I ever did a release :browser-test build myself, so no clue 😛

Adam Helins10:01:11

Hmmm, then I guess I must have been actually compiling instead of releasing, I've been doing a lot of task shuffling. I like testing in release mode, some might call me paranoid 😛

thheller10:01:57

or it absolutely make sense to test in release mode. I strongly recommend that even

💯 1
thheller10:01:29

(I just don't do any browser based testing myself)

Adam Helins10:01:23

With Karma being deprecated, I've been looking for a simple setup to do headless browser testing, without all the fuzz. Generally speaking, I also wanted something that works without any involving setup. My current approach is to have a very simple runner namespace that merely runs tests so that results are console.logged, and use Playwright to simply open the page, capture and print the output from the JVM, and exit with 1 if some test failures are detected. Minimalistic but it works well, Playwright even takes care of downloading browsers under the hood. Just mentioning it here in case someone is doing something similar. Finishing some stuff but I'll be probably releasing that idea this month.

👀 1
mikerod21:01:01

I did something similar with puppeteer

mikerod21:01:37

Ended up adding a bunch of test output printing reports and parallel test running etc. made a whole ad hoc lib internally around it.

Eric Dvorsak11:01:12

how does one require a pure esm module like this one with shadow-cljs? https://github.com/syntax-tree/unist-util-visit-parents/blob/main/package.json it doesn't have any of the entry-keys ["module" "browser" "main"]

thheller11:01:31

(:require ["unist-util-visit-parents" :as x])?

thheller11:01:06

I vaguely remember seeing this package before recently? does it throw an error or something?

Eric Dvorsak12:01:30

yeah I'm getting The required JS dependency "unist-util-visit-parents/do-not-use-color" is not available, it was required by "node_modules/unist-util-visit-parents/lib/index.js". with your statement above

thheller12:01:48

and you are sure that this exactly that package.json on your disk and not some other version?

thheller12:01:59

node_modules/unist-util-visit-parents/package.json

Eric Dvorsak12:01:34

{
  "name": "unist-util-visit-parents",
  "version": "6.0.1",
  "description": "unist utility to recursively walk over nodes, with ancestral information",
  "license": "MIT",
  "keywords": [
    "unist",
    "unist-util",
    "util",
    "utility",
    "tree",
    "ast",
    "visit",
    "traverse",
    "walk",
    "check",
    "parent",
    "parents"
  ],
  "repository": "syntax-tree/unist-util-visit-parents",
  "bugs": "",
  "funding": {
    "type": "opencollective",
    "url": ""
  },
  "author": "Titus Wormer <[email protected]> ()",
  "contributors": [
    "Titus Wormer <[email protected]> ()"
  ],
  "sideEffects": false,
  "type": "module",
  "exports": {
    ".": "./index.js",
    "./do-not-use-color": {
      "node": "./lib/color.node.js",
      "default": "./lib/color.js"
    }
  },
  "types": "index.d.ts",
  "files": [
    "lib/",
    "index.d.ts",
    "index.js"
  ],
  "dependencies": {
    "@types/unist": "^3.0.0",
    "unist-util-is": "^6.0.0"
  },
  "devDependencies": {
    "@types/hast": "^3.0.0",
    "@types/mdast": "^4.0.0",
    "@types/node": "^20.0.0",
    "@types/xast": "^2.0.0",
    "c8": "^8.0.0",
    "mdast-util-from-markdown": "^1.0.0",
    "mdast-util-gfm": "^2.0.0",
    "micromark-extension-gfm": "^2.0.0",
    "prettier": "^2.0.0",
    "remark-cli": "^11.0.0",
    "remark-preset-wooorm": "^9.0.0",
    "strip-ansi": "^7.0.0",
    "tsd": "^0.28.0",
    "type-coverage": "^2.0.0",
    "typescript": "^5.0.0",
    "xo": "^0.54.0"
  },
  "scripts": {
    "prepack": "npm run build && npm run format",
    "build": "tsc --build --clean && tsc --build && tsd && type-coverage",
    "format": "remark . -qfo && prettier . -w --loglevel warn && xo --fix",
    "test-api": "node --conditions development test.js",
    "test-coverage": "c8 --100 --reporter lcov npm run test-api",
    "test": "npm run build && npm run format && npm run test-coverage"
  },
  "prettier": {
    "bracketSpacing": false,
    "semi": false,
    "singleQuote": true,
    "tabWidth": 2,
    "trailingComma": "none",
    "useTabs": false
  },
  "remarkConfig": {
    "plugins": [
      "remark-preset-wooorm"
    ]
  },
  "typeCoverage": {
    "atLeast": 100,
    "detail": true,
    "#": "needed `any`s",
    "ignoreFiles": [
      "lib/index.d.ts"
    ],
    "ignoreCatch": true,
    "strict": true
  },
  "xo": {
    "prettier": true
  }
}

thheller12:01:34

very easy to have some version conflict or whatever and you getting something else than expected

Eric Dvorsak12:01:10

pasted the package module from my node_modules above

Eric Dvorsak12:01:53

could it be because the exports has a nested map?

"exports": {
    ".": "./index.js",
    "./do-not-use-color": {
      "node": "./lib/color.node.js",
      "default": "./lib/color.js"
    }

thheller12:01:30

hmm no thats normal

thheller12:01:41

I think something is getting confused because the package is requiring itself basically

thheller12:01:59

might be a bug. busy with something else currently

thheller12:01:05

will check it in a bit

thheller12:01:05

as a temp fix you can probably change

import {color} from 'unist-util-visit-parents/do-not-use-color'
in that lib/index.js to
import {color} from './color.js'

Eric Dvorsak12:01:50

yeah with that change it compiled

Eric Dvorsak12:01:37

although the orginal library that I tried to import as more cases than just this one

thheller12:01:26

yeah likely a bug in my code. will check later.

thheller17:01:40

yep, was a bug. should be fixed in 2.26.4

Eric Dvorsak17:01:59

Awesome thanks!

Eric Dvorsak06:01:44

It works now thanks!

juhoteperi13:01:08

Does externs inference work when using :js-provider :external? I got a bunch of new infer-warnings when switching to it. Probably makes sense that if Closure doesn't read the JS files, the type information it inferred can't be used.

thheller18:01:04

correct. what isn't processed can't be used for inference

thheller18:01:59

I actually considered adding a flag that always disables looking at the "extra" collected properties, so that you'd always get the warning

juhoteperi18:01:01

A mention the guide close on js-provider section could be helpful? I didn't at least notice one. Or in externs inference section.

thheller18:01:46

more curious about what it found? like an actual missing extern or just a false positive?

juhoteperi18:01:24

I'll check tomorrow 👍