I'm curious if anyone ran into the same error usin...
# sst
s
I'm curious if anyone ran into the same error using sst app with typescript. I'm using typescript config
baseUrl
to resolve module file path relative to baseUrl . Typescript does recognized the path but it's failing on build. I wonder if this is esbuild limitation or something else. From the looks of it in .build file, the path is not being resolved.
Copy code
Running type checker
Deploying stacks

Error: Cannot find module 'util/domain'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/Users/sionelt/projects/enterprise/lib/integrations-app.ts:10:46)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
f
@Jay any idea why this is happening?
s
Ok this is odd. So it works if i change the dir name to something else other than
util
. The dir is in at the root. I happen to read through sst scripts source code trying to understand how esbuild is being used and I noticed that it has a dir name called
util
as well. I wonder would that be why, it's trying to find my file in that dir?! Anyways its working now when i rename it from
util
j
Let me take a look at this later today.
@Sione I'd like to work on this. How I can I reproduce this issue?
s
oh yes, thanks. Here's a reproduce sst app repo: https://github.com/sionelt/sst-app-example. Error is thrown when I import file from a dir named
util
at the root that uses typescript baseUrl config to resolve path.
@Jay if dir name other than
util
then it will work and resolve the import on build.
j
Perfect. Appreciate you putting it together.
I posted this over on esbuild https://github.com/evanw/esbuild/issues/966 I'm not too familiar with how TS resolves these imports but does it not work because
util
is a built-in?
s
@Jay appreciate opening that issue on esbuild, very informative. Not a deal breaker, but great to learn about util being a node built-in module.