Skip to content

Commit

Permalink
Revert "feat: allow to import TS files with js extension (#3536)" (#3559
Browse files Browse the repository at this point in the history
)
  • Loading branch information
chenjiahan authored Sep 25, 2024
1 parent 6ac2c5f commit e3e6cb5
Show file tree
Hide file tree
Showing 14 changed files with 8 additions and 115 deletions.
10 changes: 0 additions & 10 deletions e2e/cases/typescript/extension-alias/index.test.ts

This file was deleted.

3 changes: 0 additions & 3 deletions e2e/cases/typescript/extension-alias/src/bar.tsx

This file was deleted.

1 change: 0 additions & 1 deletion e2e/cases/typescript/extension-alias/src/foo.ts

This file was deleted.

12 changes: 0 additions & 12 deletions e2e/cases/typescript/extension-alias/src/index.ts

This file was deleted.

12 changes: 0 additions & 12 deletions e2e/cases/typescript/extension-alias/tsconfig.json

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
28 changes: 0 additions & 28 deletions packages/compat/webpack/tests/__snapshots__/default.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -325,13 +325,6 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
},
],
"resolve": {
"extensionAlias": {
".js": [
".ts",
".tsx",
".js",
],
},
"extensions": [
".ts",
".tsx",
Expand Down Expand Up @@ -690,13 +683,6 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when produ
},
],
"resolve": {
"extensionAlias": {
".js": [
".ts",
".tsx",
".js",
],
},
"extensions": [
".ts",
".tsx",
Expand Down Expand Up @@ -1004,13 +990,6 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when targe
},
],
"resolve": {
"extensionAlias": {
".js": [
".ts",
".tsx",
".js",
],
},
"extensions": [
".ts",
".tsx",
Expand Down Expand Up @@ -1301,13 +1280,6 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when targe
},
],
"resolve": {
"extensionAlias": {
".js": [
".ts",
".tsx",
".js",
],
},
"extensions": [
".ts",
".tsx",
Expand Down
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@
"reduce-configs": "^1.0.0",
"rsbuild-dev-middleware": "0.1.1",
"rslog": "^1.2.3",
"rspack-chain": "^1.0.3",
"rspack-chain": "^1.0.1",
"rspack-manifest-plugin": "5.0.1",
"sirv": "^2.0.4",
"style-loader": "3.3.4",
Expand Down
17 changes: 2 additions & 15 deletions packages/core/src/plugins/resolve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@ function applyFullySpecified({
.resolve.set('fullySpecified', false);
}

function applyExtensions({
chain,
tsconfigPath,
}: {
chain: RspackChain;
tsconfigPath: string | undefined;
}) {
function applyExtensions({ chain }: { chain: RspackChain }) {
const extensions = [
// most projects are using TypeScript, resolve .ts(x) files first to reduce resolve time.
'.ts',
Expand All @@ -42,13 +36,6 @@ function applyExtensions({
];

chain.resolve.extensions.merge(extensions);

if (tsconfigPath) {
// TypeScript allows importing TS files with `.js` extension
chain.resolve.extensionAlias.merge({
'.js': ['.ts', '.tsx', '.js'],
});
}
}

function applyAlias({
Expand Down Expand Up @@ -103,7 +90,7 @@ export const pluginResolve = (): RsbuildPlugin => ({
handler: (chain, { environment, CHAIN_ID }) => {
const { config, tsconfigPath } = environment;

applyExtensions({ chain, tsconfigPath });
applyExtensions({ chain });

applyAlias({
chain,
Expand Down
28 changes: 0 additions & 28 deletions packages/core/tests/__snapshots__/default.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -373,13 +373,6 @@ exports[`applyDefaultPlugins > should apply default plugins correctly 1`] = `
"alias": {
"@swc/helpers": "<ROOT>/node_modules/<PNPM_INNER>/@swc/helpers",
},
"extensionAlias": {
".js": [
".ts",
".tsx",
".js",
],
},
"extensions": [
".ts",
".tsx",
Expand Down Expand Up @@ -809,13 +802,6 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when prod
"alias": {
"@swc/helpers": "<ROOT>/node_modules/<PNPM_INNER>/@swc/helpers",
},
"extensionAlias": {
".js": [
".ts",
".tsx",
".js",
],
},
"extensions": [
".ts",
".tsx",
Expand Down Expand Up @@ -1143,13 +1129,6 @@ exports[`applyDefaultPlugins > should apply default plugins correctly when targe
"alias": {
"@swc/helpers": "<ROOT>/node_modules/<PNPM_INNER>/@swc/helpers",
},
"extensionAlias": {
".js": [
".ts",
".tsx",
".js",
],
},
"extensions": [
".ts",
".tsx",
Expand Down Expand Up @@ -1550,13 +1529,6 @@ exports[`tools.rspack > should match snapshot 1`] = `
"alias": {
"@swc/helpers": "<ROOT>/node_modules/<PNPM_INNER>/@swc/helpers",
},
"extensionAlias": {
".js": [
".ts",
".tsx",
".js",
],
},
"extensions": [
".ts",
".tsx",
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit e3e6cb5

Please sign in to comment.