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 custom tsconfig #102

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/utils/get-rollup-configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
) => {
const [dts, ts] = await Promise.all([
import('rollup-plugin-dts'),
import('typescript'),

Check warning on line 48 in src/utils/get-rollup-configs.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Maximum number of dependencies (15) exceeded
]);
return {
input: [] as string[],
Expand All @@ -59,6 +59,7 @@
),
resolveTypescriptMjsCts(),
dts.default({
tsconfig: tsconfig?.path,
Copy link
Owner Author

Choose a reason for hiding this comment

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

Wait, this already exists on L84...

respectExternal: true,

/**
Expand All @@ -80,7 +81,7 @@
module: ts.default.ModuleKind.Preserve,
moduleResolution: ts.default.ModuleResolutionKind.Bundler,
},
tsconfig: tsconfig?.path,

Check failure on line 84 in src/utils/get-rollup-configs.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

An object literal cannot have multiple properties with the same name.
}) as Plugin,
],
output: [] as unknown as Output,
Expand Down Expand Up @@ -169,7 +170,7 @@
aliases: AliasMap,
packageJson: PackageJson,
tsconfig: TsConfigResult | null,
) => {

Check warning on line 173 in src/utils/get-rollup-configs.ts

View workflow job for this annotation

GitHub Actions / Test (ubuntu-latest)

Async arrow function has too many parameters (7). Maximum allowed is 5
const executablePaths = inputs
.filter(({ exportEntry }) => exportEntry.isExecutable)
.map(({ exportEntry }) => exportEntry.outputPath);
Expand Down
42 changes: 42 additions & 0 deletions tests/specs/builds/typescript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -215,5 +215,47 @@ export default testSuite(({ describe }, nodePath: string) => {
expect(pkgrollProcess.exitCode).toBe(1);
// expect(pkgrollProcess.stderr).toMatch('Cannot resolve tsconfig at path:');
});

test('should pass custom tsconfig.json to dts module', async () => {
const fixture = await createFixture({
...installTypeScript,
src: {
'index.tsx': 'export default () => (<div>hi</div>);',
},
'package.json': createPackageJson({
main: './dist/index.js',
dependencies: {
working: '*',
},
}),
'tsconfig.json': createTsconfigJson({
compilerOptions: {
jsx: 'react-jsx',
jsxImportSource: 'breaking',
},
}),
'tsconfig.build.json': createTsconfigJson({
compilerOptions: {
jsx: 'react-jsx',
jsxImportSource: 'working',
},
}),
});

const pkgrollProcess = await pkgroll([
'--env.NODE_ENV=test',
'--tsconfig=tsconfig.build.json',
], {
cwd: fixture.path,
nodePath,
reject: false,
});

expect(pkgrollProcess.exitCode).toBe(0);
expect(pkgrollProcess.stderr).toBe('');

const code = await fixture.readFile('dist/index.js', 'utf8');
expect(code).toMatch('working');
});
});
});
Loading