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 77492ca commit 62ab6d2
Show file tree
Hide file tree
Showing 31 changed files with 72 additions and 75 deletions.
24 changes: 10 additions & 14 deletions babel.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,11 @@ export default api => {
],
['@babel/preset-typescript']
);
if (modules === 'commonjs') {
plugins.push([
'@babel/plugin-transform-modules-commonjs',
{
importInterop: 'node'
}
]);
}
plugins.push(
[
'esm-resolver',
'module-replace',
{
source: {
extensions: [
[['.js', '.mjs', '.jsx', '.mjsx', '.ts', '.tsx'], ext]
]
}
replace: [[/^(\.\.?\/.+)\.(m|c)?tsx?$/i, `$1${ext}`]]
}
],
[
Expand All @@ -66,6 +54,14 @@ export default api => {
}
]
);
if (modules === 'commonjs') {
plugins.push([
'@babel/plugin-transform-modules-commonjs',
{
importInterop: 'node'
}
]);
}
return {
presets,
plugins
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 @@ -75,7 +75,7 @@
"@stylistic/eslint-plugin": "^2.6.1",
"@types/node": "^22.1.0",
"@types/source-map-support": "^0.5.10",
"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
6 changes: 3 additions & 3 deletions src/command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import {
DEBUG_ERROR_LOG,
UPDATE_INTERVAL_DEFAULT,
UPDATE_INTERVAL_ENV
} from './constants';
import {divmod, envTrue, envInteger} from './util';
import {Progress, ProgressCallback} from './progress';
} from './constants.ts';
import {divmod, envTrue, envInteger} from './util.ts';
import {Progress, ProgressCallback} from './progress.ts';

// eslint-disable-next-line unicorn/prefer-export-from
export {Help, Flags, Args, run};
Expand Down
4 changes: 2 additions & 2 deletions src/commands/about.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {
VERSION as SHOCKPKG_CORE_VERSION
} from '@shockpkg/core';

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

/**
* About command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/available.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags} from '../command';
import {Command, Flags} from '../command.ts';

/**
* Available command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/cleanup.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags} from '../command';
import {Command, Flags} from '../command.ts';

/**
* Cleanup command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/file.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags, Args} from '../command';
import {Command, Flags, Args} from '../command.ts';

/**
* File command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/help.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags, Args, Help} from '../command';
import {Command, Flags, Args, Help} from '../command.ts';

/**
* Help command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/info.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags, Args} from '../command';
import {Command, Flags, Args} from '../command.ts';

/**
* Info command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/install.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags, Args} from '../command';
import {Command, Flags, Args} from '../command.ts';

/**
* Install command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/installed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags} from '../command';
import {Command, Flags} from '../command.ts';

/**
* Installed command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/is-current.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags, Args} from '../command';
import {Command, Flags, Args} from '../command.ts';

/**
* IsCurrent command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/is-installed.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags, Args} from '../command';
import {Command, Flags, Args} from '../command.ts';

/**
* IsInstalled command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/is-obsolete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags, Args} from '../command';
import {Command, Flags, Args} from '../command.ts';

/**
* IsObsolete command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/list.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags} from '../command';
import {Command, Flags} from '../command.ts';

/**
* List command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/obsolete.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags} from '../command';
import {Command, Flags} from '../command.ts';

/**
* Obsolete command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/outdated.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags} from '../command';
import {Command, Flags} from '../command.ts';

/**
* Outdated command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/path.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags} from '../command';
import {Command, Flags} from '../command.ts';

/**
* Path command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/remove.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags, Args} from '../command';
import {Command, Flags, Args} from '../command.ts';

/**
* Remove command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/update.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags} from '../command';
import {Command, Flags} from '../command.ts';

/**
* Update command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/upgrade.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags} from '../command';
import {Command, Flags} from '../command.ts';

/**
* Upgrade command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/url.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags} from '../command';
import {Command, Flags} from '../command.ts';

/**
* Url command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/verify.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command, Flags, Args} from '../command';
import {Command, Flags, Args} from '../command.ts';

/**
* Verify command.
Expand Down
2 changes: 1 addition & 1 deletion src/commands/version.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Command} from '../command';
import {Command} from '../command.ts';

/**
* Version command.
Expand Down
52 changes: 26 additions & 26 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
export * from './meta';
export * from './constants';
export * from './util';
export * from './progress';
export * from './command';
export * from './commands/about';
export * from './commands/available';
export * from './commands/cleanup';
export * from './commands/file';
export * from './commands/help';
export * from './commands/info';
export * from './commands/install';
export * from './commands/installed';
export * from './commands/is-current';
export * from './commands/is-installed';
export * from './commands/is-obsolete';
export * from './commands/list';
export * from './commands/obsolete';
export * from './commands/outdated';
export * from './commands/path';
export * from './commands/remove';
export * from './commands/update';
export * from './commands/upgrade';
export * from './commands/url';
export * from './commands/verify';
export * from './commands/version';
export * from './meta.ts';
export * from './constants.ts';
export * from './util.ts';
export * from './progress.ts';
export * from './command.ts';
export * from './commands/about.ts';
export * from './commands/available.ts';
export * from './commands/cleanup.ts';
export * from './commands/file.ts';
export * from './commands/help.ts';
export * from './commands/info.ts';
export * from './commands/install.ts';
export * from './commands/installed.ts';
export * from './commands/is-current.ts';
export * from './commands/is-installed.ts';
export * from './commands/is-obsolete.ts';
export * from './commands/list.ts';
export * from './commands/obsolete.ts';
export * from './commands/outdated.ts';
export * from './commands/path.ts';
export * from './commands/remove.ts';
export * from './commands/update.ts';
export * from './commands/upgrade.ts';
export * from './commands/url.ts';
export * from './commands/verify.ts';
export * from './commands/version.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/test/commands/about.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {describe, it} from 'node:test';
import {ok, strictEqual} from 'node:assert';

import {cli} from '../../util.spec';
import {cli} from '../../util.spec.ts';

void describe('about', () => {
void it('output', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/test/commands/help.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {describe, it} from 'node:test';
import {ok, strictEqual} from 'node:assert';

import {cli} from '../../util.spec';
import {cli} from '../../util.spec.ts';

void describe('help', () => {
void it('output', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/test/commands/version.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {describe, it} from 'node:test';
import {ok, strictEqual} from 'node:assert';

import {cli} from '../../util.spec';
import {cli} from '../../util.spec.ts';

void describe('version', () => {
void it('output', async () => {
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 62ab6d2

Please sign in to comment.