Skip to content

es6-global modules have incorrect paths when compiling dependencies via npm link #1691

Closed
@TheSpyder

Description

@TheSpyder

I'm experimenting with a project setup where I develop both the main library and a dependency at the same time. I have both repositories local on my machine during development. This works well enough if I npm install the dependency from the local filesystem, but then I need to reinstall after every change in the dependency. I would like to use npm link to solve this, but bsb is producing incorrect paths for es6-global modules when I try.

Given the folder structure in the attached tarball, run the following commands:

cd foo
npm link bs-platform ../bar
bsb -make-world

If you then cat lib/es6_global/src/foo.js, Bar is referenced as import * as Bar from "../../../node_modules/bar/lib/es6_global/src/bar.js"; which is loading it via the symlink.

However, if you cat node_modules/bar/lib/es6_global/src/bar.js, the path to the stdlib is wrong:
import * as $$String from "../../../../foo/node_modules/bs-platform/lib/es6/string.js";

This appears to have resolved the real filesystem location of the stdlib in foo relative to bar.js, ignoring the fact that it was compiled as a symlinked dependency. In other words it will work if bar.js is loaded from the real filesystem location, but not the symlink location (and as shown above foo.js is loading it through the symlink).

I can think of two solutions:

  1. When compiling bar, use stdlib references that work via the symlink
  2. When compiling foo, refer to bar through the actual filesystem location instead of via the symlink

I don't think option 1 is really viable though, as it would mean that moving back to working in the bar project directly leaves you with compiled output that no longer works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions