Skip to content

Avoid indirect imports in tsconfig.json and package.json #260

Closed
@thomaspeugeot

Description

@thomaspeugeot

Situation:

  • gongc performs a few npm install commands (such as jointjs) at the initialisation because they will be needed by gongdoc
  • gongc adds some import path to the tsconfig.json file because they will be needed by gongdoc, gongleaflet, ...

Problem:

  • those are indirect depedencies and they should not be explicit. For instance, if the dependency in gongdoc changes, all package that depends on gongdoc need to be changed.

Solution:

    "scripts": {
        "install-gongdocdiagrams": "npm install --prefix ../vendor/github.com/fullstack-lang/gongdoc/ng/projects/gongdocdiagrams",
        "postinstall": "npm run install-gongdocdiagrams"
    },

in vendor\github.com\fullstack-lang\gongdoc\ng\projects\gongdocdiagrams\package.json

{
    "name": "gongdocdiagrams",
    "version": "0.0.1",
    "dependencies": {
        "@types/backbone": "^1.4.15",
        "@types/jointjs": "^2.0.0",
        "@types/jquery": "^3.5.16",
        "@types/leaflet": "^1.9.0",
        "@types/lodash": "^4.14.191",
        "backbone": "^1.4.0",
        "install": "^0.13.0",
        "jointjs": "^3.6.5",
        "jquery": "^3.5.1",
        "lodash": "^4.17.20",
        "ng": "file:../../../../../../../ng"
    }
}

problem, it duplicates a full local install and it might be deleted during a go mod vendor command

in the tsconfig.json, add

  "extends": "../vendor/github.com/fullstack-lang/gongdoc/ng/projects/gongdocdiagrams/tsconfig.lib.json",

in the vendor/github.com/fullstack-lang/gongdoc/ng/tsconfig.json

{
  // we cannot extends the global ../../tsconfig.json file because it is not embedded
  "compilerOptions": {
...
    "jointjs": [
      "./node_modules/jointjs"
    ],
...
}

repo github.com\thomaspeugeot\helloworld

has a working configuration

When go mod vendor is performed, it deleted the node_modules directory, therefore a npm install has to be performed again. This is 30' but this is acceptable.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions