Skip to content

Missing feature resolveFullPaths #60

Open

Description

I'm using swc to build a project that works with modules

{
// ...
"type": "module"
// ...
}

when I build using the swc cli it doesn't resolve all the paths and puts .js at the end

examples

import { database } from '#/database/drizzle'

should look like this when the build is complete

import { database } from './database/drizzle.js'

There should be an option to resolve fullpaths like this package implements.
Using this package you can use an argument that resolves all paths

https://www.npmjs.com/package/tsc-alias

// ...
  "tsc-alias": {
    "resolveFullPaths": true
  }
/// ....

Activity

  1. luas10c commented on Oct 12, 2024

    @luas10c
    Author

    I need to do it this way to solve the problem.

    \\ ...
      "scripts": {
        // ...
        "build": "swc src -d dist --strip-leading-paths --delete-dir-on-start && tsc-alias"
        // ...
      }
    // ...

    .swcrc

    {
      "$schema": "https://swc.rs/schema.json",
      "jsc": {
        "baseUrl": ".",
        "parser": {
          "syntax": "typescript"
        },
        "target": "es2020",
        "paths": {
          "#/*": ["./src/*"]
        }
      },
      "module": {
        "type": "es6",
        "strict": true
      }
    }

    tsconfig.json

    {
      "compilerOptions": {
        "strict": true,
        "skipLibCheck": true,
        "esModuleInterop": true,
    
        "target": "es2022",
        "module": "es2020",
        "moduleResolution": "node",
    
        "outDir": "dist",
    
        "allowSyntheticDefaultImports": true,
    
        "paths": {
          "#/*": ["./src/*"]
        }
      },
      "tsc-alias": {
        "resolveFullPaths": true
      }
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions