Closed zachsa closed 1 year ago
Looking at the release notes for version 4, I see that a peer dependency is required. After installing the peer dependency version 4 worked:
Here is the package.json - https://github.com/d3/d3-contour/blob/main/package.json. there is no peer dependency specified. It looks to me like this is an error in the library, as I would not expect JSPM to pick up on peer deps without those being explicit. But if this is the case, could this be included in the error message?
I wasn't able to reproduce this issue in a simple way. Here is a simple repo that works
package.json
{
"type": "module",
"dependencies": {
"@jspm/generator": "^1.0.0-beta.37",
"d3-contour": "^4.0.0"
}
}
jspm.js
import { Generator } from '@jspm/generator'
import { readFile, writeFile } from 'fs/promises'
import { pathToFileURL } from 'url'
import mkdirp from 'mkdirp'
import { dirname } from 'path'
const NODE_ENV = process.env.NODE_ENV || 'development'
const DEP = 'index.html'
const TARGET = 'output.html'
const generator = new Generator({
mapUrl: pathToFileURL(TARGET),
env: ['browser', NODE_ENV, 'module'],
defaultProvider: 'jspm',
})
const htmlSource = await readFile(DEP, 'utf-8')
const pins = await generator.addMappings(htmlSource)
const html = await generator.htmlInject(htmlSource, {
trace: true,
pins,
preload: false,
integrity: false,
esModuleShims: true,
})
mkdirp.sync(dirname(TARGET))
await writeFile(TARGET, html)
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<script src="index.js" type="module"></script>
</head>
</html>
Result
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<!-- Generated by @jspm/generator - https://github.com/jspm/generator -->
<script async src="https://ga.jspm.io/npm:es-module-shims@1.5.17/dist/es-module-shims.js" crossorigin="anonymous"></script>
<script type="importmap">
{
"imports": {
"d3-contour": "https://ga.jspm.io/npm:d3-contour@4.0.0/src/index.js"
},
"scopes": {
"https://ga.jspm.io/": {
"d3-array": "https://ga.jspm.io/npm:d3-array@3.2.0/src/index.js",
"internmap": "https://ga.jspm.io/npm:internmap@2.0.3/src/index.js"
}
}
}
</script>
<script src="index.js" type="module"></script>
</head>
</html>
However, in my project where I found the error, if I don't specifically include the d3-array
dependency in my package.json, then I get the error. So this package.json file doesn't work:
{
"name": "somisana-web",
"version": "1.0.0",
"type": "module",
"description": "SOMISANA web stack",
"author": "zd.smith@saeon.nrf.ac.za",
"dependencies": {
"@apollo/client": "^3.6.9",
"@arcgis/core": "^4.24.7",
"@emotion/cache": "^11.10.3",
"@emotion/react": "^11.10.4",
"@emotion/server": "^11.10.0",
"@emotion/styled": "^11.10.4",
"@graphql-tools/schema": "^9.0.2",
"@jspm/generator": "^1.0.0-beta.37",
"@koa/router": "^12.0.0",
"@mdi/js": "^7.0.96",
"@mui/material": "5.10.2",
"@mui/system": "5.10.2",
"@node-loader/core": "^2.0.0",
"@node-loader/import-maps": "^1.1.0",
"@rollup/plugin-replace": "^4.0.0",
"@swc/cli": "^0.1.57",
"@swc/core": "^1.2.245",
"@types/react": "^18.0.18",
"apollo-server-core": "^3.10.2",
"apollo-server-koa": "^3.10.2",
"browserslist": "^4.21.3",
"cookie": "^0.5.0",
"d3-contour": "^4.0.0",
"dataloader": "^2.1.0",
"dotenv": "^16.0.2",
"echarts": "^5.3.3",
"echarts-for-react": "^3.0.2",
"graphql": "16.6",
"graphql-type-json": "^0.3.2",
"install": "^0.13.0",
"JSONStream": "^1.3.5",
"koa": "^2.13.4",
"koa-bodyparser": "^4.3.0",
"koa-compress": "^5.1.0",
"koa-mount": "^4.0.0",
"koa-static": "^5.0.0",
"make-fetch-happen": "^10.2.1",
"maplibre-gl": "2.4.0",
"mime": "^3.0.0",
"mkdirp": "^1.0.4",
"mongodb": "^4.9.0",
"pg": "^8.8.0",
"pg-query-stream": "^4.2.4",
"prettier": "^2.7.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-markdown": "^8.0.3",
"react-router-dom": "^6.3.0",
"rimraf": "^3.0.2",
"rollup": "^2.79.0",
"rollup-plugin-import-css": "^3.0.3",
"rollup-plugin-swc": "^0.2.1",
"sift": "^16.0.0",
"swc-loader": "^0.2.3",
"tinygradient": "^1.1.5",
"wkt": "^0.1.1"
}
}
But it would be very difficult to provide an isolated example of the particular imports that cause this
I'm sorry but I'm unable to run this replication. I tried your example but it executes fine. Please provide one that can fully replicate the issue. It's better to provide a git repo than copy-paste as well.
I can't replicate either. closing
Hi,
After running
npm install d3-contour
and trying to generate a client import map, I get:What can cause this? If it's not immediately obvious please let me know and I will see if I can isolate and reproduce it. This is for version
^4.0.0
. But version^3.0.0
works fine