bdon / observable-framework-maps

static site generator for maps + static site generator for data apps
https://bdon.github.io/observable-framework-maps/
9 stars 2 forks source link

Unable to develop locally or deploy with a different repo using the same markdown file and pmtiles dataset #2

Closed jaanli closed 6 months ago

jaanli commented 6 months ago

When creating a new repository, the following leads to source invalid errors after copying the example markdown file and data dependency from this repository:

This yields the following error:

Error: Invalid source undefined

With the JavaScript console error log:

socket open
client.js:440 ↑ Object
client.js:133 Error: Invalid source undefined
    at e (_esm.js:7:81805)
    at Ae (_esm.js:7:81995)
    at new e (_esm.js:7:91750)
    at Module.ii (_esm.js:7:95048)
    at body (example-map:78:24)
    at define (runtime.js:1318:33)
rejected @ client.js:133
favicon.ico:1 

       Failed to load resource: the server responded with a status of 404 (Not Found)
undefined:1 

       Failed to load resource: the server responded with a status of 404 (Not Found)
_esm.js:7 Error: Bad response code: 404
    at oe.<anonymous> (_esm.js:7:13731)
    at Generator.next (<anonymous>)
    at s (_esm.js:7:66)

I tried the following to debug:

I might be missing something basic as it's my first time doing something like this.

package.json from this:

{
  "type": "module",
  "private": true,
  "scripts": {
    "clean": "rimraf docs/.observablehq/cache",
    "build": "rimraf dist && observable build",
    "dev": "observable preview",
    "deploy": "observable deploy",
    "observable": "observable"
  },
  "dependencies": {
    "@observablehq/framework": "latest",
    "d3-dsv": "^3.0.1",
    "d3-time-format": "^4.1.0"
  },
  "devDependencies": {
    "rimraf": "^5.0.5"
  },
  "engines": {
    "node": ">=18"
  }
}
jaanli commented 6 months ago

Trying something like a bisect here - looks like the above commands work on an earlier version of Observable Framework:

cp observable-framework-maps/docs/data/cb_2018_us_zcta510_500k_nolimit.pmtiles american-community-survey/docs/data/
cp observable-framework-maps/docs/example-map.md american-community-survey/docs
cd american-community-survey
yarn dev

This runs fine.

package.json from https://github.com/jaanli/american-community-survey/ -

{
  "type": "module",
  "private": true,
  "scripts": {
    "clean": "rm -rf docs/.observablehq/cache",
    "build": "rm -rf dist && observable build",
    "dev": "observable preview",
    "deploy": "observable deploy",
    "observable": "observable"
  },
  "dependencies": {
    "@observablehq/framework": "latest",
    "d3-dsv": "^3.0.1",
    "d3-time-format": "^4.1.0"
  },
  "engines": {
    "node": ">=20.6"
  }
}

cc @Fil in case you have ideas? It looks like something changed that breaks usage of examples between Observable Framework versions - perhaps the addition of rimraf?

Fil commented 6 months ago

Can you reduce the bug to a minimal reproduction?

Fil commented 6 months ago

Try to replace FileAttachment(x)._url with either await FileAttachment(x).url() or FileAttachment(x).href. Since v1.5.0 this (private) property has been removed, which explains the "undefined". https://github.com/observablehq/framework/releases/tag/v1.5.0

jaanli commented 6 months ago

That was it, thank you for the help @Fil !!! Unblocked on this :) filed a pull request: https://github.com/bdon/observable-framework-maps/pull/3 glad we figured out the breaking change!

Fil commented 6 months ago

I'd also suggest not to close this issue while #3 is still open. In the description of #3 you would write, on a separate line, "closes #2", and GitHub will automatically close this issue when #3 is merged :)