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

How does '@esbuild-plugins/tsconfig-paths' work? #6

Open
RyannGalea opened this issue Jul 16, 2021 · 5 comments
Open

How does '@esbuild-plugins/tsconfig-paths' work? #6

RyannGalea opened this issue Jul 16, 2021 · 5 comments

Comments

@RyannGalea
Copy link

Really trying to solve an issue with resolving paths when building with esbuild and it seems this project will do that? At some point, not sure how to use it in its current form?

@acidoxee
Copy link

Hi, same question here! Is this plugin ready for consumption? The checkmark in the readme seems to indicate so, but I don't think it is yet? At least it doesn't seem to work out of the box for me. A little help would be greatly appreciated 😉

@RyannGalea
Copy link
Author

RyannGalea commented Jan 12, 2022

@acidoxee I resorted to using 'tsc-alias' & babel, couldn't get esbuild to work with my Typescript project.

@kritzware
Copy link

The tsconfig-paths plugin also seems to do nothing for me out of the box. Is this plugin working for anyone else?

@rickklaasboer
Copy link

Managed to get it working as follows:

const esbuild = require('esbuild');
const {TsconfigPathsPlugin} = require('@esbuild-plugins/tsconfig-paths');

esbuild
    .serve(
        {servedir: 'public', port: 3000},
        {
            bundle: true,
            outfile: 'public/js/app.js',
            entryPoints: ['./src/index.tsx'],
            minify: true,
            define: {
                global: 'window',
            },
            inject: ['./esbuild/react-shim.js'],
            plugins: [TsconfigPathsPlugin({tsconfig: './tsconfig.json'})],
        },
    )
    .catch((err) => console.log(err));
{
    "compilerOptions": {
        "target": "es2020",
        "lib": ["dom", "dom.iterable", "esnext"],
        "allowJs": true,
        "skipLibCheck": true,
        "esModuleInterop": true,
        "allowSyntheticDefaultImports": true,
        "strict": true,
        "forceConsistentCasingInFileNames": true,
        "noFallthroughCasesInSwitch": true,
        "module": "esnext",
        "moduleResolution": "node",
        "resolveJsonModule": true,
        "isolatedModules": true,
        "noEmit": true,
        "jsx": "react-jsx",
        "baseUrl": "./",
        "paths": {
            "@/*": ["./src/*"]
        }
    },
    "include": ["src"]
}

The default export coming from @esbuild-plugins/tsconfig-paths doesn't seem to work.

@AllanOricil
Copy link

@rickklaasboer I had the same problem and your solution solved it. Thank you.

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

5 participants