Skip to content
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

[Bug]: Recognise setting a baseUrl in tsconfig #1250

Closed
jckw opened this issue Dec 26, 2021 · 3 comments
Closed

[Bug]: Recognise setting a baseUrl in tsconfig #1250

jckw opened this issue Dec 26, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@jckw
Copy link

jckw commented Dec 26, 2021

What version of Remix are you using?

1.0.6

What version of Node are you using? Minimum supported version is 14.

16.13.0

Steps to Reproduce

When using the standard Remix starter, add the following line to the tsconfig.json.

{
  ... 
  "baseUrl": "./",
  ...
}

Create some file in the root of the project, e.g. stitches.config.ts, for https://stitches.dev/

// ./stitches.config.ts

export default {
  whatever: "I'm just a demo"
}

Import this file somewhere else in your application, and use it, e.g. in ./app/routes/index.tsx.

Now run:

yarn dev

and navigate to http://localhost:3000

Expected Behavior

The app should run and show the normal remix index page.

Actual Behavior

Error: Cannot find module 'stitches.config'

Require stack:
- /Users/jack/example-project/api/_build/index.js
- /Users/jack/example-project/node_modules/@remix-run/serve/index.js
- /Users/jack/example-project/node_modules/@remix-run/dev/cli/commands.js
- /Users/jack/example-project/node_modules/@remix-run/dev/cli.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/jack/example-project/api/_build/index.js:745:35)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
@jckw jckw added the bug Something isn't working label Dec 26, 2021
@jckw
Copy link
Author

jckw commented Dec 27, 2021

Just as an additional note: it looks like this should already be supported by Esbuild evanw/esbuild#60

@cairin
Copy link

cairin commented Feb 25, 2022

I too ran into this problem. It seems that remix and/or the version of esbuild being used don't take into consideration the baseUrl typescript config option.

I set up the starter application with typescript configured as per the Remix typescript guidelines. Running tsc --traceResolution gives the following output:

======== Resolving module 'stitches.config' from '/path/to/remix/project/app/routes/index.tsx'. ========
Explicitly specified module resolution kind: 'NodeJs'.
'baseUrl' option is set to '/path/to/remix/project', using this value to resolve non-relative module name 'stitches.config'.
'paths' option is specified, looking for a pattern to match module name 'stitches.config'.
'baseUrl' option is set to '/path/to/remix/project', using this value to resolve non-relative module name 'stitches.config'.
Resolving module name 'stitches.config' relative to base url '/path/to/remix/project' - '/path/to/remix/project/stitches.config'.
Loading module as file / folder, candidate module location '/path/to/remix/project/stitches.config', target file type 'TypeScript'.
File '/path/to/remix/project/stitches.config.ts' exist - use it as a name resolution result.
======== Module name 'stitches.config' was successfully resolved to '/path/to/remix/project/stitches.config.ts'. ========

You can see that typescript resolves the module fine.
This is easily solved by moving the module into the /app directory. But would be nice to be able to import modules outside the /app such as generated files etc.

@mcansh mcansh added the needs-response We need a response from the original author about this issue/PR label Aug 1, 2022
@mcansh
Copy link
Collaborator

mcansh commented Aug 1, 2022

hey folks, sorry for not popping in here sooner, but i have good news.

baseUrl support should've been included when we introduced support for custom tsconfig/jsconfig path aliases in 1.3.5

@mcansh mcansh closed this as completed Aug 16, 2022
@MichaelDeBoey MichaelDeBoey removed the needs-response We need a response from the original author about this issue/PR label Oct 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants