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

feat: allow overrding tsconfig path #489

Merged
merged 9 commits into from
Mar 13, 2024

Conversation

juliusmarminge
Copy link
Contributor

@juliusmarminge juliusmarminge commented Mar 13, 2024

Allows using a custom path for tsconfig during build. Useful if you for example have one tsconfig for editor experience and a different one for build

(ref https://github.com/pingdotgg/uploadthing/tree/main/packages/uploadthing - base tsconfig has path overrides to resolve source code types during dev, but we don't want the built output to use those paths)
CleanShot 2024-03-13 at 17 15 13@2x

Comment on lines 488 to 496
{
name: 'tsconfig-override',
dir: 'tsconfig-override',
args: ['--tsconfig', 'tsconfig.build.json'],
async expected(dir) {
expect(await existsFile(join(dir, './dist/index.js'))).toBe(true)
expect(await existsFile(join(dir, './dist/index.d.ts'))).toBe(true)
},
},
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 don't know a nice simple test here to assure we did use the provided tsconfig path. ideas?

name: 'tsconfig-override',
dir: 'tsconfig-override',
args: ['--tsconfig', 'tsconfig.build.json'],
async expected(dir) {
Copy link
Owner

Choose a reason for hiding this comment

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

One way is to test target, you can do es5, then you get var in the output, and another one is still es8 by default.

We're using the new way to write interagtion test now, you can checkout #484 to see how we do it now. Basically have a new index.test.ts under that folder and put test there. so we can run them as a standalone test

Copy link
Contributor Author

Choose a reason for hiding this comment

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

rewrote the test!

join(dir, './dist/index.js'),
'utf-8',
)
expect(content).toContain('export { index as default };')
Copy link
Owner

Choose a reason for hiding this comment

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

the checking result is reversed? this should be es5

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the outputs I'm getting 👀

// target: esnext
var index = (()=>'index');

export { index as default };

// target: es5
function index() {
    return "index";
}

export { index as default };

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 agree it kinda does seem weird though...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it is using the correct tsconfig though 🤔

CleanShot 2024-03-14 at 00 23 51@2x

Copy link
Owner

Choose a reason for hiding this comment

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

I see 👍
I changed to class, it looks easier to understand between function and class now

Copy link
Owner

@huozhi huozhi left a comment

Choose a reason for hiding this comment

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

Thanks!

@huozhi huozhi merged commit 81eaadd into huozhi:main Mar 13, 2024
3 checks passed
juliusmarminge added a commit to juliusmarminge/bunchee that referenced this pull request Mar 13, 2024
huozhi pushed a commit that referenced this pull request Mar 13, 2024
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

Successfully merging this pull request may close these issues.

None yet

2 participants