cli: remove support for implicit module extensions + allow .?ts
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -27,7 +27,7 @@ import { existsSync } from 'fs';
|
||||
const DEFAULT_MODULE_FORMAT = 'commonjs';
|
||||
|
||||
// Source file extensions to look for when using bundle resolution strategy
|
||||
const EXTS = ['.ts', '.js', '.mts', '.cts', '.mjs', '.cjs'];
|
||||
const SRC_EXTS = ['.ts', '.js'];
|
||||
const TS_EXTS = ['.ts', '.mts', '.cts'];
|
||||
const moduleTypeTable = {
|
||||
'.mjs': 'module',
|
||||
@@ -177,7 +177,7 @@ async function findPackageJSON(startPath) {
|
||||
|
||||
/** @type {import('module').ResolveHook} */
|
||||
async function resolveWithoutExt(specifier, context, nextResolve) {
|
||||
for (const tryExt of EXTS) {
|
||||
for (const tryExt of SRC_EXTS) {
|
||||
try {
|
||||
const resolved = await nextResolve(specifier + tryExt, {
|
||||
...context,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"allowImportingTsExtensions": true,
|
||||
"allowJs": true,
|
||||
"declaration": true,
|
||||
"declarationMap": false,
|
||||
|
||||
@@ -233,16 +233,7 @@ export async function makeRollupConfigs(
|
||||
plugins: [
|
||||
resolve({
|
||||
mainFields,
|
||||
extensions: [
|
||||
'.ts',
|
||||
'.js',
|
||||
'.tsx',
|
||||
'.jsx',
|
||||
'.mts',
|
||||
'.cts',
|
||||
'.mjs',
|
||||
'.cjs',
|
||||
],
|
||||
extensions: SCRIPT_EXTS,
|
||||
}),
|
||||
commonjs({
|
||||
include: /node_modules/,
|
||||
|
||||
@@ -20,11 +20,11 @@ import * as depCommonJs from 'dep-commonjs';
|
||||
// import * as depModule from 'dep-module';
|
||||
import * as depDefault from 'dep-default';
|
||||
import { value as namedA } from './a-named';
|
||||
// import { value as namedB } from './b-named';
|
||||
import { value as namedC } from './c-named';
|
||||
// import { value as namedB } from './b-named.mts';
|
||||
import { value as namedC } from './c-named.cts';
|
||||
import { default as defaultA } from './a-default';
|
||||
// import { default as defaultB } from './b-default';
|
||||
import { default as defaultC } from './c-default';
|
||||
// import { default as defaultB } from './b-default.mts';
|
||||
import { default as defaultC } from './c-default.cts';
|
||||
|
||||
async function resolveAll(obj): Promise<unknown> {
|
||||
const val = await obj;
|
||||
@@ -61,10 +61,10 @@ export const values = resolveAll({
|
||||
},
|
||||
dyn: {
|
||||
namedA: import('./a-named').then(m => m.default.value),
|
||||
namedB: import('./b-named').then(m => m.value),
|
||||
namedC: import('./c-named').then(m => m.default.value),
|
||||
namedB: import('./b-named.mts').then(m => m.value),
|
||||
namedC: import('./c-named.cts').then(m => m.default.value),
|
||||
defaultA: import('./a-default').then(m => m.default.default),
|
||||
defaultB: import('./b-default').then(m => m.default),
|
||||
defaultC: import('./c-default').then(m => m.default.default),
|
||||
defaultB: import('./b-default.mts').then(m => m.default),
|
||||
defaultC: import('./c-default.cts').then(m => m.default.default),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -20,11 +20,11 @@ import * as depCommonJs from 'dep-commonjs';
|
||||
// import * as depModule from 'dep-module';
|
||||
import * as depDefault from 'dep-default';
|
||||
import { value as namedA } from './a-named';
|
||||
// import { value as namedB } from './b-named';
|
||||
import { value as namedC } from './c-named';
|
||||
// import { value as namedB } from './b-named.mts';
|
||||
import { value as namedC } from './c-named.cts';
|
||||
import { default as defaultA } from './a-default';
|
||||
// import { default as defaultB } from './b-default';
|
||||
import { default as defaultC } from './c-default';
|
||||
// import { default as defaultB } from './b-default.mts';
|
||||
import { default as defaultC } from './c-default.cts';
|
||||
|
||||
async function resolveAll(obj): Promise<unknown> {
|
||||
const val = await obj;
|
||||
@@ -61,10 +61,10 @@ export const values = resolveAll({
|
||||
},
|
||||
dyn: {
|
||||
namedA: import('./a-named').then(m => m.default.value),
|
||||
namedB: import('./b-named').then(m => m.value),
|
||||
namedC: import('./c-named').then(m => m.default.value),
|
||||
namedB: import('./b-named.mts').then(m => m.value),
|
||||
namedC: import('./c-named.cts').then(m => m.default.value),
|
||||
defaultA: import('./a-default').then(m => m.default.default),
|
||||
defaultB: import('./b-default').then(m => m.default),
|
||||
defaultC: import('./c-default').then(m => m.default.default),
|
||||
defaultB: import('./b-default.mts').then(m => m.default),
|
||||
defaultC: import('./c-default.cts').then(m => m.default.default),
|
||||
},
|
||||
});
|
||||
|
||||
@@ -20,11 +20,11 @@ import * as depCommonJs from 'dep-commonjs';
|
||||
import * as depModule from 'dep-module';
|
||||
import * as depDefault from 'dep-default';
|
||||
import { value as namedA } from './a-named';
|
||||
import { value as namedB } from './b-named';
|
||||
import { value as namedC } from './c-named';
|
||||
import { value as namedB } from './b-named.mts';
|
||||
import { value as namedC } from './c-named.cts';
|
||||
import defaultA from './a-default';
|
||||
import defaultB from './b-default';
|
||||
import cDefault from './c-default';
|
||||
import defaultB from './b-default.mts';
|
||||
import cDefault from './c-default.cts';
|
||||
|
||||
const { default: defaultC } = cDefault;
|
||||
|
||||
@@ -63,10 +63,10 @@ export const values = resolveAll({
|
||||
},
|
||||
dyn: {
|
||||
namedA: import('./a-named').then(m => m.value),
|
||||
namedB: import('./b-named').then(m => m.value),
|
||||
namedC: import('./c-named').then(m => m.default.value),
|
||||
namedB: import('./b-named.mts').then(m => m.value),
|
||||
namedC: import('./c-named.cts').then(m => m.default.value),
|
||||
defaultA: import('./a-default').then(m => m.default),
|
||||
defaultB: import('./b-default').then(m => m.default),
|
||||
defaultC: import('./c-default').then(m => m.default.default),
|
||||
defaultB: import('./b-default.mts').then(m => m.default),
|
||||
defaultC: import('./c-default.cts').then(m => m.default.default),
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user