-
Notifications
You must be signed in to change notification settings - Fork 360
Description
I'm a bit suprised nobody else reported this yet, but from my understanding, the import paths are wrong when one vis-* package attempts to import from another vis-* package. They use internal paths, which is forbidden by the addition of the newly added exports field in the package.json of each vis-* package.
As far as I can tell, this affects not only vis-timeline, but other packages such as vis-data as well.
I see in the recent version of vis-*, you updated to package entry points in your package.json, where you explicitly define the paths from which one can import (via the exports field).
However, that also means other package can only import from those paths; and no other paths. When we build (primefaces/primefaces#13998), we now get errors like this:
✘ [ERROR] Could not resolve request: <vis-util/esnext/esm/vis-util.js> against importer: </home/user/git/primefaces/primefaces/src/main/frontend/.yarn/__virtual__/vis-data-virtual-154f58cd9b/0/cache/vis-data-npm-8.0.1-6b8505875f-7653f514e5.zip/node_modules/vis-data/esnext/esm/vis-data.mjs>: Error: Package subpath './esnext/esm/vis-util.js' is not defined by "exports" in /home/madgaksha/git/primefaces/primefaces/src/main/frontend/.yarn/__virtual__/vis-util-virtual-56dd6ad871/0/cache/vis-util-npm-6.0.0-3090c5318c-8e7dc67a60.zip/node_modules/vis-util/package.json imported from /home/madgaksha/git/primefaces/primefaces/src/main/frontend/.yarn/__virtual__/vis-data-virtual-154f58cd9b/0/cache/vis-data-npm-8.0.1-6b8505875f-7653f514e5.zip/node_modules/vis-data/esnext/esm/vis-data.mjs [plugin load-from-expression]
.yarn/__virtual__/vis-data-virtual-154f58cd9b/0/cache/vis-data-npm-8.0.1-6b8505875f-7653f514e5.zip/node_modules/vis-data/esnext/esm/vis-data.mjs:27:37:
27 │ import { pureDeepObjectAssign } from 'vis-util/esnext/esm/vis-util.js';
or
✘ [ERROR] Could not resolve request: <vis-data/esnext/esm/vis-data.js> against importer: </home/user/git/primefaces/primefaces/src/main/frontend/.yarn/__virtual__/vis-timeline-virtual-b3f564c857/0/cache/vis-timeline-npm-8.2.1-cd489b0e05-68f2b29fe9.zip/node_modules/vis-timeline/esnext/esm/vis-timeline-graph2d.mjs>: Error: Package subpath './esnext/esm/vis-data.js' is not defined by "exports" in /home/madgaksha/git/primefaces/primefaces/src/main/frontend/.yarn/__virtual__/vis-data-virtual-154f58cd9b/0/cache/vis-data-npm-8.0.1-6b8505875f-7653f514e5.zip/node_modules/vis-data/package.json imported from /home/madgaksha/git/primefaces/primefaces/src/main/frontend/.yarn/__virtual__/vis-timeline-virtual-b3f564c857/0/cache/vis-timeline-npm-8.2.1-cd489b0e05-68f2b29fe9.zip/node_modules/vis-timeline/esnext/esm/vis-timeline-graph2d.mjs [plugin load-from-expression]
.yarn/__virtual__/vis-timeline-virtual-b3f564c857/0/cache/vis-timeline-npm-8.2.1-cd489b0e05-68f2b29fe9.zip/node_modules/vis-timeline/esnext/esm/vis-timeline-graph2d.mjs:30:93:
30 │ import { isDataViewLike as isDataViewLike$1, DataSet, createNewDataPipeFrom, DataView } from 'vis-data/esnext/esm/vis-data.js';
╵ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The reason for the second error is that vis-timeline attempts to import from vis-data via internal paths, which is forbidden due to the exports field in the package.json. For example, for the second error above, if we take a look at https://app.unpkg.com/[email protected]/files/esnext/esm/vis-timeline-graph2d.mjs, that file contains:
import * as util from 'vis-util/esnext/esm/vis-util.js';
import { isNumber, isString, getType } from 'vis-util/esnext/esm/vis-util.js';
import { isDataViewLike as isDataViewLike$1, DataSet, createNewDataPipeFrom, DataView } from 'vis-data/esnext/esm/vis-data.js';As vis-data and vis-util are different packages, this must be:
import * as util from 'vis-util/esnext';
import { isNumber, isString, getType } from 'vis-util/esnext';
import { isDataViewLike as isDataViewLike$1, DataSet, createNewDataPipeFrom, DataView } from 'vis-data/esnext';Similarly, for the first error, vis-data attempts to import files from vis-util via internal paths, see https://app.unpkg.com/[email protected]/files/esnext/esm/vis-data.mjs
As for how to fix this, I think it seems like a build issue? In the source code, the import appears to be correct, e.g. vis-data/src/data-set.ts:
import { pureDeepObjectAssign } from "vis-util/esnext";