Skip to content

Commit

Permalink
Import ts with extension
Browse files Browse the repository at this point in the history
  • Loading branch information
JrMasterModelBuilder committed Aug 6, 2024
1 parent 3858b1e commit b3f0854
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 16 deletions.
8 changes: 2 additions & 6 deletions babel.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,9 @@ export default api => {
);
plugins.push(
[
'esm-resolver',
'module-replace',
{
source: {
extensions: [
[['.js', '.mjs', '.jsx', '.mjsx', '.ts', '.tsx'], ext]
]
}
replace: [[/^(\.\.?\/.+)\.(m|c)?tsx?$/i, `$1${ext}`]]
}
],
[
Expand Down
10 changes: 5 additions & 5 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"@eslint/js": "^9.8.0",
"@stylistic/eslint-plugin": "^2.6.1",
"@types/node": "^22.1.0",
"babel-plugin-esm-resolver": "^3.0.0",
"babel-plugin-module-replace": "^1.0.1",
"babel-plugin-search-and-replace": "^1.1.1",
"eslint": "^9.8.0",
"eslint-config-prettier": "^9.1.0",
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './meta';
export * from './mounter';
export * from './meta.ts';
export * from './mounter.ts';
2 changes: 1 addition & 1 deletion src/meta.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {describe, it} from 'node:test';
import {match} from 'node:assert';

import {NAME, VERSION} from './meta';
import {NAME, VERSION} from './meta.ts';

void describe('meta', () => {
void it('NAME', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/mounter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {deepStrictEqual, ok, strictEqual} from 'node:assert';
import {lstat, readdir} from 'node:fs/promises';
import {platform, release} from 'node:os';

import {Mounter} from './mounter';
import {Mounter} from './mounter.ts';

const fixtures = './spec/fixtures';

Expand Down
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"module": "commonjs",
"moduleResolution": "Node",
"allowSyntheticDefaultImports": true,
"allowImportingTsExtensions": true,
"lib": ["ESNext"],
"newLine": "lf",

Expand Down

0 comments on commit b3f0854

Please sign in to comment.