Skip to content

Using tsconfig.json baseUrl and paths #28

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
toniopelo opened this issue May 29, 2020 · 5 comments
Closed

Using tsconfig.json baseUrl and paths #28

toniopelo opened this issue May 29, 2020 · 5 comments

Comments

@toniopelo
Copy link
Contributor

toniopelo commented May 29, 2020

Hi,

I tried to have it work with this package:
https://github.com/dividab/tsconfig-paths-webpack-plugin

and this snippet added to preact.config.js:

    config.resolve.plugins = [
      ...(config.resolve.plugins || []),
      new TsconfigPathsPlugin({ logInfoToStdOut: true })
    ]

But I get

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object
    at validateString (internal/validators.js:112:11)
    at Object.join (path.js:1040:7)
    at tryPrefix (/Users/antoine/Workspaces/enseignerleclimat/frontend-next/node_modules/less/dist/less.cjs.js:211:53)
    at tryPathIndex (/Users/antoine/Workspaces/enseignerleclimat/frontend-next/node_modules/less/dist/less.cjs.js:270:23)
    at tryPrefix (/Users/antoine/Workspaces/enseignerleclimat/frontend-next/node_modules/less/dist/less.cjs.js:268:29)
    at ReadFileContext.<anonymous> (/Users/antoine/Workspaces/enseignerleclimat/frontend-next/node_modules/less/dist/less.cjs.js:260:48)
    at ReadFileContext.callback (/Users/antoine/Workspaces/enseignerleclimat/frontend-next/node_modules/graceful-fs/graceful-fs.js:123:16)
    at FSReqCallback.readFileAfterOpen [as oncomplete] (fs.js:250:13)
error Command failed with exit code 1.

when executing yarn dev

I was wondering if this couldn't be added by default in the config template ?

@rschristian
Copy link
Member

rschristian commented May 30, 2020

Your solution works for me, but your errors seem Less related. I don't think this is your issue. Probably doing something the Less Loader doesn't appreciate. Could be wrong though.

@toniopelo
Copy link
Contributor Author

Thanks for the fast reply!
I had to downgrade less-loader to 5.0.0 instead of 6.x.x to make it work with preact-cli@2.2.1 as explained in this comment:
preactjs/preact-cli#1173 (comment)

It might be an issue like tsconfig-paths-webpack-plugin needs less-loader@6.x.x and preact-cli@2.2.1 needs less-loader@5.x.x.

What are your versions of these tools ?

@rschristian
Copy link
Member

Thanks for the fast reply!

I had to downgrade less-loader to 5.0.0 instead of 6.x.x to make it work with preact-cli@2.2.1 as explained in this comment:

preactjs/preact-cli#1173 (comment)

It might be an issue like tsconfig-paths-webpack-plugin needs less-loader@6.x.x and preact-cli@2.2.1 needs less-loader@5.x.x.

What are your versions of these tools ?

Yeah, I thought that error looked familiar. I was messing around with Less recently and that came up.

The Paths Plugin shouldn’t care about the Less Loader at all. Completely separate things. I can’t imagine that it would cause issues.

Does it still throw the same error though?

@toniopelo
Copy link
Contributor Author

I just find out the issue.
A @import had a non-existing path in one of my less imports.
The error is kind of confusing...

I introduced this error at the same time I added the tsconfig-paths-webpack-plugin.
Closing this as non related to this repo.

Thanks for your time, have a nice day!

@rschristian
Copy link
Member

Glad you solved it.

If you still were interested in adding the plugin to this template, you can make a PR with that change. That way you can run it by the actual maintainers of these templates, and get their thoughts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants