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

rspack.config.ts configuration error #3609

Closed
ICJR opened this issue Jun 22, 2023 · 4 comments
Closed

rspack.config.ts configuration error #3609

ICJR opened this issue Jun 22, 2023 · 4 comments
Labels

Comments

@ICJR
Copy link

ICJR commented Jun 22, 2023

System Info

System:
OS: Windows 10 10.0.19045
CPU: (12) x64 Intel(R) Core(TM) i7
Memory: 20.73 GB / 31.91 GB
Binaries:
Node: 18.12.0 - C:\Program Files\n
npm: 9.2.0 - C:\Program Files\node
Browsers:
Edge: Spartan (44.19041.1266.0), C
Internet Explorer: 11.0.19041.1566

Details

I've installed ts-node and converted my rspack.config.js file to a typescript file but I believe the docs are incorrect and ts support does not work with export default

documentation shows configuration object being exported using export = config I don't think that's valid ( vscode throws an error as well )

When I use export default config I receive

Configuration error:
- Unrecognized key(s) in object: 'default'

Reproduce link

No response

Reproduce Steps

Create a rspack config using typescript
Build

@ICJR ICJR added bug Something isn't working pending triage The issue/PR is currently untouched. labels Jun 22, 2023
@hyf0
Copy link
Collaborator

hyf0 commented Jun 22, 2023

I could help you solve the issue with a long conversation, but the simplest way is to use rspack.config.js.

If you want type checking with rspack.config.js, add @ts-check and @type {import('@rspack/cli').Configuration}.

https://www.rspack.dev/config/#type-checking

// @ts-check

/** @type {import('@rspack/cli').Configuration} */
const config = {
  entry: {
    main: './src/index.js',
  },
};
module.exports = config;

@hyf0 hyf0 added question and removed bug Something isn't working pending triage The issue/PR is currently untouched. labels Jun 22, 2023
@hyf0
Copy link
Collaborator

hyf0 commented Jun 22, 2023

export = xxx is a valid syntax in typescript. The error you met is probably caused by an improper tsconfig.json.

https://www.typescriptlang.org/docs/handbook/modules.html#export--and-import--require

@ICJR ICJR closed this as completed Jun 23, 2023
@hardfist
Copy link
Contributor

we should support export default case in future, let me test whether #3222 fix it

@hardfist
Copy link
Contributor

@ICJR it's supported now, you can test on @rspack/cli@0.2.3-canary-bd53ec4-20230623050741

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants