alias icon indicating copy to clipboard operation
alias copied to clipboard

Doesn't work with monorepo projects

Open gjsoaresc opened this issue 4 years ago • 2 comments

Everytime the lib tries to get the relative main root so I had to change final configuration to work with.

My tsconfig.json image

Configuration assign image

gjsoaresc avatar Feb 21 '21 19:02 gjsoaresc

Can you describe what you expect it to work like exactly? I'm not sure I understand how you are expecting it to work. I'd love to implement whatever functionality you need

dhkatz avatar Jul 12 '21 06:07 dhkatz

I just tried this out as well. I got this message:

Error: Unable to find the 'paths' property in the supplied configuration!

I believe the problem stems from the parser somehow just ending at resolving the base configuration (of which you extend).


Did a MWE. Suppose here's the setup.

.
├── gulpfile.js
├── package.json
├── src
│   ├── one
│   │   ├── index.ts
│   │   └── tsconfig.json
│   ├── two
│   └── shared
│       └── lib.ts
├── tsconfig.json
└── yarn.lock

tsconfig.json

{
  "compilerOptions": {
    "module": "esnext",
    "target": "esnext",
    "strict": true,
    "declaration": true,
    "removeComments": true,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "incremental": true
  }
}

and src/one/tsconfig.json

{
  "extends": "../../tsconfig.json",
  "compilerOptions": {
    "rootDir": "../",
    "outDir": "../dist/one",
    "paths": {
      "@/*": ["./*"],
      "@shared/*": ["../shared/*"]
    }
  },
  "includes": [
    "./",
    "../shared",
    "../node_modules"
  ],
  "exclude": [
    "../two"
  ]
}

Here's the gulp task for reference:

const tsProject = ts.createProject("./src/one/tsconfig.json");

gulp.task("ts-project", () => {
  const compilation = gulp
    .src("./src/one/**/*.ts")
    .pipe(alias(tsProject.config))
    .pipe(tsProject());

  return compilation.js.pipe(gulp.dest("./dist"));
});

Looks like the options in the resolveConfig function (this line) gives the following when you print it out.

{
  config: {
    compilerOptions: {
      module: 'esnext',
      target: 'esnext',
      strict: true,
      declaration: true,
      removeComments: true,
      moduleResolution: 'node',
      emitDecoratorMetadata: true,
      experimentalDecorators: true,
      allowSyntheticDefaultImports: true,
      sourceMap: true,
      incremental: true
    },
    compileOnSave: false
  },
  error: undefined
}

Could it perhaps be a problem upstream?

japorized avatar Sep 23 '21 14:09 japorized