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

[Bug]: module.rule.type is 'json', occur error: message = unreachable: unknow module type: json; #8785

Open
Tracked by #8445
GiveMe-A-Name opened this issue Dec 20, 2024 · 2 comments
Labels
bug Something isn't working team The issue/pr is created by the member of Rspack.

Comments

@GiveMe-A-Name
Copy link
Member

System Info

System:
OS: macOS 13.6.5
CPU: (10) arm64 Apple M1 Pro
Memory: 163.13 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Yarn: 1.22.19 - /opt/homebrew/bin/yarn
npm: 10.9.0 - ~/Library/Application Support/fnm/node-versions/v22.12.0/installation/bin/npm
pnpm: 9.15.0 - ~/Library/pnpm/pnpm
bun: 1.0.21 - ~/.bun/bin/bun
Browsers:
Chrome: 131.0.6778.204
Safari: 16.6

Details

When Module.rule.type is 'json', it will occur a error message = unreachable: unknow module type: json; stack = Error: unreachable: unknow module type: json.

const toml = require("toml");

/** @type {import("@rspack/core").Configuration[]} */
module.exports = [
	{
		mode: "development",
		module: {
			rules: [
				{
					test: /\.toml$/,
					type: "json",
					parser: {
						parse(input) {
							expect(arguments.length).toBe(1);
							return toml.parse(input);
						}
					}
				}
			]
		}
	}
];

Reproduce link

https://github.com/web-infra-dev/rspack/blob/main/tests/webpack-test/configCases/custom-modules/json-custom/webpack.config.js

Reproduce Steps

  1. pnpm install
  2. ./x build
  3. cd tests/webpack-test/configCases/custom-modules/json-custom/
  4. npx rspack -c webpack.config.js
@GiveMe-A-Name GiveMe-A-Name added bug Something isn't working pending triage The issue/PR is currently untouched. labels Dec 20, 2024
@GiveMe-A-Name GiveMe-A-Name changed the title [Bug]: [Bug]: module.rule.type is 'json', occur error: message = unreachable: unknow module type: json; Dec 20, 2024
@chenjiahan chenjiahan removed the pending triage The issue/PR is currently untouched. label Dec 23, 2024
@cbbfcd
Copy link
Contributor

cbbfcd commented Dec 25, 2024

Image

rspack_plugin_json is not yet fully aligned with the webpack implementation. i will do a research.

@inottn
Copy link
Collaborator

inottn commented Dec 25, 2024

rspack_plugin_json is not yet fully aligned with the webpack implementation. i will do a research.

PR welcome~

@LingyuCoder LingyuCoder added the team The issue/pr is created by the member of Rspack. label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working team The issue/pr is created by the member of Rspack.
Projects
None yet
Development

No branches or pull requests

5 participants