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

Make Wasp work with tsconfig path aliases #2457

Draft
wants to merge 34 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
382dc59
Implement project references prototype
sodic Jan 9, 2025
79924a0
Add project reference to user code from server
sodic Jan 10, 2025
4d3f95d
Push todoApp/tsconfig updated for project references
sodic Jan 10, 2025
a4ab2dd
Enable aliases in the SDK
sodic Jan 15, 2025
3fd1830
Make path aliases fully work but its ugly
sodic Jan 16, 2025
91b6f80
Clean some things up
sodic Jan 17, 2025
ae5bcaf
Add clarifying comment for rootDir
sodic Jan 17, 2025
cf3cd30
Merge branch 'filip-project-references' into filip-path-aliases
sodic Jan 17, 2025
cf1dc52
Move path aliases logic into Haskell
sodic Jan 17, 2025
611e2c0
Remove naming and remove unused code
sodic Jan 17, 2025
804852b
Improve tsconfig error messages
sodic Jan 17, 2025
302f7cf
Small refactors and error message improvements
sodic Jan 17, 2025
fe2c7c3
Remove redundant space from template
sodic Jan 17, 2025
c1cd0da
Add small refactors
sodic Jan 20, 2025
74f3567
Change [String] back to FieldPath
sodic Jan 20, 2025
09731ab
Update e2e tests
sodic Jan 20, 2025
ef1008b
Add path aliases to waspc/examples/todoApp
sodic Jan 20, 2025
7f9e078
Merge branch 'main' into filip-project-references
sodic Jan 20, 2025
2b66ac8
Merge branch 'filip-project-references' into filip-path-aliases
sodic Jan 20, 2025
9cf176e
Update waspc.cabal, e2e-tests, and todoApp to v0.16.0
sodic Jan 20, 2025
b51a56f
Fix formatting
sodic Jan 20, 2025
f36b33a
Update headless tests for 0.16.0
sodic Jan 20, 2025
6cf7730
Remove redundant testing file
sodic Jan 20, 2025
871ea87
Remove another redundant testing file
sodic Jan 20, 2025
dda6c0a
Remove more redundant testing files
sodic Jan 20, 2025
2d4c5c9
Update e2e tests
sodic Jan 21, 2025
e9ad9c3
Merge branch 'filip-project-references' into filip-path-aliases
sodic Jan 21, 2025
f390cd1
Update headless tests and waspc.cabal
sodic Jan 21, 2025
e790ebd
Merge branch 'filip-project-references' into filip-path-aliases
sodic Jan 21, 2025
e3f89ad
Merge branch 'main' into filip-path-aliases
sodic Jan 21, 2025
73a96fa
Merge branch 'main' into filip-path-aliases
sodic Jan 27, 2025
2fcc19b
Merge branch 'main' into filip-path-aliases
sodic Feb 5, 2025
ff2bf7c
Revert e2e tests
sodic Feb 5, 2025
404602d
Fully revert e2e tests
sodic Feb 5, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion waspc/data/Generator/templates/react-app/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import { mergeConfig } from "vite";
import react from "@vitejs/plugin-react";
import { defaultExclude } from "vitest/config"
import { resolveProjectPath } from "wasp/dev"
import tsconfigPaths from 'vite-tsconfig-paths'


{=# customViteConfig.isDefined =}
// Ignoring the TS error because we are importing a file outside of TS root dir.
Expand All @@ -16,7 +19,12 @@ const _waspUserProvidedConfig = {};

const defaultViteConfig = {
base: "{= baseDir =}",
plugins: [react()],
plugins: [
tsconfigPaths({
projects: ["./", resolveProjectPath("./")]
}),
react()
],
optimizeDeps: {
exclude: ['wasp']
},
Expand Down
1 change: 1 addition & 0 deletions waspc/data/Generator/templates/sdk/wasp/dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { join as joinPaths } from 'path'
* .wasp/out/web-app directory. This function resolves a project root dir path
* to be relative to the `web-app` directory i.e. `../../../projectDirPath`.
*/
// TODO: The relative path should come from Haskell
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll either solve this for the next RC or create an issue.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's old code, I think it's okay if we just create an issue for this.

export function resolveProjectPath(path: string): string {
return joinPaths('../../../', path)
}
2 changes: 1 addition & 1 deletion waspc/data/Generator/templates/sdk/wasp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
{=! expose it here (which leaks it to our users). We could avoid this by =}
{=! using relative imports inside SDK code (instead of library imports), =}
{=! but I didn't have time to implement it. =}
"./ext-src/*": "./dist/ext-src/*.js",
"./src/*": "./dist/src/*.js",
Copy link
Contributor Author

@sodic sodic Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I renamed the output folder instead of renaming aliases, seemed less fiddly. This way, the generated code's structure matches the original.

It also has a nice side effect of showing SDK build errors with correct file mappings:

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by "renaming aliases", does that mean you'd search & replace src with ext-src in the SDK version of the files?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, both there and in tsconfig paths.

{=! Used by our code, uncodumented (but accessible) for users. =}
"./operations/*": "./dist/operations/*",
{=! Used by our code, uncodumented (but accessible) for users. =}
Expand Down
11 changes: 5 additions & 6 deletions waspc/data/Generator/templates/sdk/wasp/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@
// While this is great, we still want to dig deeper at some point to understand
// better why Vite HMR misbehaves when the SDK is recompiled: https://github.com/wasp-lang/wasp/issues/1934
"incremental": true,
// todo(filip): Only works with common js, see https://www.typescriptlang.org/tsconfig#paths and daily-article.
// "paths": {
// "@wasp/*": [
// "./*.js"
// ]
// }
"paths": {
{=# paths =}
"{= path =}": ["{= lookupLocation =}"],
{=/ paths =}
}
Comment on lines +47 to +50
Copy link
Contributor Author

@sodic sodic Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the user doesn't define any aliases, this file still has an empty object.

I thought that was cleaner than doing the conditional check, but feel free to disagree :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at the compiler source code it doesn't seem like it will cause any issues 👍

},
"include": [
"."
Expand Down
12 changes: 11 additions & 1 deletion waspc/data/Generator/templates/server/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{{={= =}=}}
import esbuild from 'rollup-plugin-esbuild'
import alias from '@rollup/plugin-alias';
import resolve from '@rollup/plugin-node-resolve';

export default [
createBundle('src/server.ts', 'bundle/server.js'),
Expand All @@ -17,12 +19,20 @@ function createBundle(inputFilePath, outputFilePath) {
sourcemap: true,
},
plugins: [
resolve(),
alias({
entries: [
{=# aliases =}
{ find: '{= find =}', replacement: '{= replacement =}' },
{=/ aliases =}
]
Comment on lines +24 to +28
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE: Just like paths in sdk/tsconfig, this field's value is an empty array when the user doesn't define any aliases.

}),
esbuild({
target: 'esnext',
}),
],
// We don't want to bundle any of the node_module deps
// as we want to keep them as external dependencies
external: (id) => !/^[./]/.test(id),
external: /node_modules/,
Copy link
Contributor Author

@sodic sodic Jan 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Todo: leave a note about resolution, wasp, and bundling dependencies.

Todo: leave a note about why we're using alias and not some of the other plugins (check notes).

@infomiho I plan to explain this in detail. It's all in my notes.

}
}
33 changes: 2 additions & 31 deletions waspc/examples/todoApp/src/Todo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
type OptimisticUpdateDefinition,
createTask,
updateTaskIsDone,
deleteCompletedTasks,
toggleAllTasks,
useQuery,
getTasks,
Expand All @@ -16,8 +15,8 @@ import {
} from 'wasp/client/operations'

import React, { useState, FormEventHandler, ChangeEventHandler } from 'react'

type NonEmptyArray<T> = [T, ...T[]]
import { NonEmptyArray } from '@util'
import { Footer } from '@components/Footer'

export function areThereAnyTasks(
tasks: Task[] | undefined
Expand Down Expand Up @@ -59,34 +58,6 @@ const Todo = () => {
)
}

const Footer = ({ tasks }: { tasks: NonEmptyArray<Task> }) => {
const numCompletedTasks = tasks.filter((t) => t.isDone).length
const numUncompletedTasks = tasks.filter((t) => !t.isDone).length

const handleDeleteCompletedTasks = async () => {
try {
await deleteCompletedTasks()
} catch (err) {
console.log(err)
}
}

return (
<div className="flex justify-between">
<div>{numUncompletedTasks} items left</div>

<div>
<button
className={'btn btn-red ' + (numCompletedTasks > 0 ? '' : 'hidden')}
onClick={handleDeleteCompletedTasks}
>
Delete completed
</button>
</div>
</div>
)
}

const Tasks = ({ tasks }: { tasks: NonEmptyArray<Task> }) => {
return (
<div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { testingAction } from 'wasp/client/operations'
import { sayHi } from './util'
import { sayHi } from '@util'

export function setup() {
console.log('This was called from the client setup function')
Expand Down
31 changes: 31 additions & 0 deletions waspc/examples/todoApp/src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { NonEmptyArray } from "@util"
import { deleteCompletedTasks } from "wasp/client/operations"
import { Task } from "wasp/entities"

export const Footer = ({ tasks }: { tasks: NonEmptyArray<Task> }) => {
const numCompletedTasks = tasks.filter((t) => t.isDone).length
const numUncompletedTasks = tasks.filter((t) => !t.isDone).length

const handleDeleteCompletedTasks = async () => {
try {
await deleteCompletedTasks()
} catch (err) {
console.log(err)
}
}

return (
<div className="flex justify-between">
<div>{numUncompletedTasks} items left</div>

<div>
<button
className={'btn btn-red ' + (numCompletedTasks > 0 ? '' : 'hidden')}
onClick={handleDeleteCompletedTasks}
>
Delete completed
</button>
</div>
</div>
)
}
2 changes: 1 addition & 1 deletion waspc/examples/todoApp/src/serverSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
type MiddlewareConfigFn,
type ServerSetupFn,
} from 'wasp/server'
import { sayHi } from './util.js'
import { sayHi } from '@util'
import cors from 'cors'
import './testTypes/operations/server.js'

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
export function sayHi() {
console.log("This is coming from shared function.")
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant new lines 🤷

export type NonEmptyArray<T> = [T, ...T[]]
6 changes: 5 additions & 1 deletion waspc/examples/todoApp/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@
// Source 2: https://github.com/testing-library/jest-dom/issues/546#issuecomment-1889884843
"node_modules/@types"
],
"outDir": ".wasp/out/user"
"outDir": ".wasp/out/user",
"paths" : {
"@util": ["./src/util.js"],
"@components/*": ["./src/components/*"],
Comment on lines +45 to +46
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to test aliases with and without wildcards.

Todo: update headless.

Copy link
Contributor Author

@sodic sodic Jan 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Todo: what about more wildcards on the left side?

}
},
"include": [
"src"
Expand Down
2 changes: 2 additions & 0 deletions waspc/src/Wasp/AppSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import Wasp.AppSpec.Query (Query)
import Wasp.AppSpec.Route (Route)
import Wasp.Env (EnvVar)
import Wasp.ExternalConfig.PackageJson (PackageJson)
import Wasp.ExternalConfig.TsConfig (TsConfig)
import Wasp.Node.Version (oldestWaspSupportedNodeVersion)
import Wasp.Project.Common (SrcTsConfigFile, WaspProjectDir)
import Wasp.Project.Db.Migrations (DbMigrationsDir)
Expand All @@ -69,6 +70,7 @@ data AppSpec = AppSpec
prismaSchema :: Psl.Schema.Schema,
-- | The contents of the package.json file found in the root directory of the wasp project.
packageJson :: PackageJson,
tsConfig :: TsConfig,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to carry the path information all the way to the generator, but I'm not using anything else from the object.

Should I have only sent that?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had the same dilemma with prismaSchema since I needed only entities and not the config bits. I ended up needing the whole thing after all and when I rewrote it to include the full prismaSchema - the code felt easier to understand after I did that. I like the mental model of "we have all the project info in AppSpec that we might".

When somebody looks at AppSpec, I think it's easier to understand "Oh yes, the project tsconfig" is available vs. there is this specific paths object that we pass around. That prompts me to maybe rename it to srcTsConfig or smth like that since it might be named tsconfig.src.json as well.

-- | Absolute path to the directory containing the wasp project.
waspProjectDir :: Path' Abs (Dir WaspProjectDir),
-- | List of external code files (they are referenced/used in the declarations).
Expand Down
37 changes: 36 additions & 1 deletion waspc/src/Wasp/ExternalConfig/TsConfig.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,22 @@
module Wasp.ExternalConfig.TsConfig
( TsConfig (..),
CompilerOptions (..),
ImportPathMapping (..),
)
where

import Data.Aeson
( FromJSON,
ToJSON,
Value (..),
genericParseJSON,
parseJSON,
withObject,
)
import qualified Data.Aeson as Aeson
import Data.List.NonEmpty (NonEmpty ((:|)), nonEmpty, toList)
import Data.Map (Map)
import qualified Data.Map as M
import GHC.Generics (Generic)

data TsConfig = TsConfig
Expand All @@ -34,7 +41,9 @@ data CompilerOptions = CompilerOptions
lib :: !(Maybe [String]),
allowJs :: !(Maybe Bool),
typeRoots :: !(Maybe [String]),
outDir :: !(Maybe String)
outDir :: !(Maybe String),
baseUrl :: !(Maybe String),
paths :: !(Maybe ImportPathMapping)
}
deriving (Show, Generic)

Expand All @@ -46,3 +55,29 @@ instance FromJSON CompilerOptions where
-- "module" is a reserved keyword in Haskell, so we use "_module" instead.
modifyFieldLabel "_module" = "module"
modifyFieldLabel other = other

data ImportPathMapping
= ImportPathMapping (Map String String)
deriving (Show, Generic, ToJSON)
Comment on lines +59 to +61
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TS config path aliases point to arrays:

    "paths" : {
      "@util": ["./src/util.js"],
      "@components/*": ["./src/components/*"],
    }

Rollup aliases point to single strings:

      alias({
        entries: [
          { find: '@components', replacement: '.././src/components' },
          { find: '@util', replacement: '.././src/util.js' },
        ]
      }),

TS supports arrays because it can look for paths sequentially until it finds the correct one. Rollup can't do that.

Rollup therefore limits our entire system to one-on-one path mappings. So, I've decided to catch that as early as possible (i.e., while parsing TS config).

I should have arguably done this while validating the TS config. But then I'd have to introduce a new object (something like ValidTsConfig), and change the validateSrcTsConfig function to return it (it would then technically stop being a validator and become a constructor/parser).

I didn't do this because I wasn't sure it was the right choice and it would probably take longer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have arguably done this while validating the TS config.

Yep, this feels like a better place to perform this logic. This doesn't feel like JSON parsing logic to me.

We have this case already in the code base, the case of AppSpec being validated in Valid.hs and then we continue to use the same AppSpec object knowing it's validated. I'm not saying that's the best, but we survived :)

I'm okay with keeping this here as well, it's preventing us from constructing a faulty TsConfig - which is nice.


instance FromJSON ImportPathMapping where
parseJSON = withObject "PathMappings" $ \object -> do
originalMappings <- parseJSON (Object object)

let nonEmptyMappings = M.mapMaybe nonEmpty originalMappings
let (invalidMappings, validMappings) = M.mapEither getOnlyLookupLocationOrError nonEmptyMappings

case M.toList invalidMappings of
[] -> return $ ImportPathMapping validMappings
invalidEntries -> fail $ makeMultipleLocationsErrorMsg invalidEntries
where
getOnlyLookupLocationOrError :: NonEmpty String -> Either (NonEmpty String) String
getOnlyLookupLocationOrError = \case
lookupLocation :| [] -> Right lookupLocation
locations -> Left locations

makeMultipleLocationsErrorMsg :: [(String, NonEmpty String)] -> String
makeMultipleLocationsErrorMsg locations =
"One or more paths point to multiple lookup locations: "
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd maybe rewrite this to be a bit more clear:

Current:

One or more paths point to multiple lookup locations: [("@/*",["./src/*","./.wasp/generated/*"])]. Wasp only supports one-on-one path mappings.

Proposed:

One or more paths point to multiple lookup locations:

  "@/*": ["./src/*","./.wasp/generated/*"]

Wasp only supports one-on-one path mappings.

This matches what they see in their tsconfig better.

<> show (fmap (fmap toList) locations)
<> ". Wasp only supports one-on-one path mappings."
37 changes: 37 additions & 0 deletions waspc/src/Wasp/Generator/ImportPathAlias.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
module Wasp.Generator.ImportPathAlias
( createTsConfigPathsTemplateData,
createRollupAliasesTemplateData,
)
where

import Data.Aeson ((.=))
import qualified Data.Aeson as Aeson
import qualified Data.Map as M
import qualified StrongPath as SP
import System.FilePath ((</>))
import Wasp.ExternalConfig.TsConfig (ImportPathMapping (..))
import Wasp.Project.Common (waspProjectDirFromSrcDir)
import Wasp.Util (stripSuffixIfPresent)

createTsConfigPathsTemplateData :: Maybe ImportPathMapping -> [Aeson.Value]
createTsConfigPathsTemplateData = \case
Nothing -> []
Just (ImportPathMapping mappings) -> map makePathObjectEntry $ M.toList mappings
where
makePathObjectEntry (path, lookupLocation) =
Aeson.object
[ "path" .= path,
"lookupLocation" .= lookupLocation
]

createRollupAliasesTemplateData :: Maybe ImportPathMapping -> [Aeson.Value]
createRollupAliasesTemplateData = \case
Nothing -> []
Just (ImportPathMapping mappings) -> map makeAliasTemplateData $ M.toList mappings
where
makeAliasTemplateData (path, lookupLocation) =
Aeson.object
[ "find" .= stripWildcardPath path,
"replacement" .= (SP.fromRelDir waspProjectDirFromSrcDir </> stripWildcardPath lookupLocation)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd like to see some examples in comments above or even better unit tests for this transformation :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will definitely add those.

Also, I have to figure out whether prefixing with ../ works for aliases in nested files.

]
stripWildcardPath = stripSuffixIfPresent "/*"
11 changes: 7 additions & 4 deletions waspc/src/Wasp/Generator/SdkGenerator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import qualified Wasp.AppSpec.App.Dependency as AS.Dependency
import qualified Wasp.AppSpec.ExternalFiles as EC
import Wasp.AppSpec.Valid (getLowestNodeVersionUserAllows, isAuthEnabled)
import qualified Wasp.AppSpec.Valid as AS.Valid
import qualified Wasp.ExternalConfig.TsConfig as TC
import Wasp.Generator.Common
( ProjectRootDir,
makeJsonWithEntityData,
Expand All @@ -37,6 +38,7 @@ import Wasp.Generator.DbGenerator (getEntitiesForPrismaSchema)
import qualified Wasp.Generator.DbGenerator.Auth as DbAuth
import Wasp.Generator.FileDraft (FileDraft)
import qualified Wasp.Generator.FileDraft as FD
import Wasp.Generator.ImportPathAlias (createTsConfigPathsTemplateData)
import Wasp.Generator.Monad (Generator)
import qualified Wasp.Generator.NpmDependencies as N
import Wasp.Generator.SdkGenerator.AuthG (genAuth)
Expand Down Expand Up @@ -101,7 +103,7 @@ genSdk spec =
genFileCopy [relfile|dev/index.ts|],
genFileCopy [relfile|client/config.ts|],
genServerConfigFile spec,
genTsConfigJson,
genTsConfigJson spec,
genServerUtils spec,
genPackageJson spec,
genDbClient spec
Expand Down Expand Up @@ -252,15 +254,16 @@ genServerConfigFile spec = return $ C.mkTmplFdWithData relConfigFilePath tmplDat

-- todo(filip): remove this duplication, we have almost the same thing in the
-- ServerGenerator.
genTsConfigJson :: Generator FileDraft
genTsConfigJson = do
genTsConfigJson :: AppSpec -> Generator FileDraft
genTsConfigJson spec = do
return $
C.mkTmplFdWithDstAndData
[relfile|tsconfig.json|]
[relfile|tsconfig.json|]
( Just $
object
[ "majorNodeVersion" .= show (SV.major NodeVersion.oldestWaspSupportedNodeVersion)
[ "majorNodeVersion" .= show (SV.major NodeVersion.oldestWaspSupportedNodeVersion),
"paths" .= createTsConfigPathsTemplateData (TC.paths $ TC.compilerOptions $ AS.tsConfig spec)
]
)

Expand Down
5 changes: 1 addition & 4 deletions waspc/src/Wasp/Generator/SdkGenerator/Common.hs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ sdkTemplatesDirInTemplatesDir :: Path' (Rel TemplatesDir) (Dir SdkTemplatesDir)
sdkTemplatesDirInTemplatesDir = [reldir|sdk/wasp|]

extSrcDirInSdkRootDir :: Path' (Rel SdkRootDir) (Dir GeneratedExternalCodeDir)
extSrcDirInSdkRootDir = [reldir|ext-src|]
extSrcDirInSdkRootDir = [reldir|src|]

relDirToRelFileP :: Path Posix (Rel d) Dir' -> Path Posix (Rel d) File'
relDirToRelFileP path = fromJust $ SP.parseRelFileP $ removeTrailingSlash $ SP.fromRelDirP path
Expand All @@ -73,9 +73,6 @@ relDirToRelFileP path = fromJust $ SP.parseRelFileP $ removeTrailingSlash $ SP.f
makeSdkImportPath :: Path Posix (Rel SdkRootDir) File' -> Path Posix (Rel s) File'
makeSdkImportPath path = [reldirP|wasp|] </> path

extCodeDirInSdkRootDir :: Path' (Rel SdkRootDir) Dir'
extCodeDirInSdkRootDir = [reldir|ext-src|]

clientTemplatesDirInSdkTemplatesDir :: Path' (Rel SdkTemplatesDir) (Dir ClientTemplatesDir)
clientTemplatesDirInSdkTemplatesDir = [reldir|client|]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,5 +174,5 @@ extImportToJsImport extImport@(EI.ExtImport extImportName extImportPath) =
}
where
importPath = C.makeSdkImportPath $ dropExtensionFromImportPath $ extCodeDirP </> SP.castRel extImportPath
extCodeDirP = fromJust $ SP.relDirToPosix C.extCodeDirInSdkRootDir
extCodeDirP = fromJust $ SP.relDirToPosix C.extSrcDirInSdkRootDir
importName = GJI.extImportNameToJsImportName extImportName
Loading
Loading