Skip to content

Commit e1168a2

Browse files
authored
feat!: defaults fixedExtension to true when platform is node (#517)
1 parent 7de20b2 commit e1168a2

File tree

56 files changed

+158
-160
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+158
-160
lines changed

src/config/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ async function resolveUserConfig(
210210
cjsDefault = true,
211211
globImport = true,
212212
inlineOnly,
213+
fixedExtension = platform === 'node',
213214
} = userConfig
214215

215216
const logger = createLogger(logLevel, { customLogger, failOnWarn })
@@ -343,6 +344,7 @@ async function resolveUserConfig(
343344
cjsDefault,
344345
globImport,
345346
inlineOnly,
347+
fixedExtension,
346348
}
347349

348350
return config

src/config/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ export interface UserConfig {
287287
* Use a fixed extension for output files.
288288
* The extension will always be `.cjs` or `.mjs`.
289289
* Otherwise, it will depend on the package type.
290-
* @default false
290+
*
291+
* Defaults to `true` if `platform` is set to `node`, `false` otherwise.
291292
*/
292293
fixedExtension?: boolean
293294

@@ -504,7 +505,6 @@ export type ResolvedConfig = Overwrite<
504505
| 'alias'
505506
| 'external'
506507
| 'onSuccess'
507-
| 'fixedExtension'
508508
| 'outExtensions'
509509
| 'hooks'
510510
| 'copy'

tests/__snapshots__/banner-and-footer-option.snap.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
## index.d.ts
1+
## index.d.mts
22

3-
```ts
3+
```mts
44
// dts banner
55
export { };
66
// dts footer
77
```
88

9-
## index.js
9+
## index.mjs
1010

11-
```js
11+
```mjs
1212
// js banner
1313
//#region index.ts
1414
console.log("Hello, world!");

tests/__snapshots__/basic.snap.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## index.js
1+
## index.mjs
22

3-
```js
3+
```mjs
44
//#region index.ts
55
console.log("Hello, world!");
66

tests/__snapshots__/bundle-dts.snap.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## index.d.ts
1+
## index.d.mts
22

3-
```ts
3+
```mts
44
//#region src/utils/types.d.ts
55
declare let str: string;
66
//#endregion
@@ -10,9 +10,9 @@ declare let shared: number;
1010
export { shared, str };
1111
```
1212

13-
## index.js
13+
## index.mjs
1414

15-
```js
15+
```mjs
1616
//#region src/utils/types.ts
1717
let str = "hello";
1818

tests/__snapshots__/cjs-default.snap.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@ declare function hello(): void;
1919
export = hello;
2020
```
2121

22-
## index.d.ts
22+
## index.d.mts
2323

24-
```ts
24+
```mts
2525
//#region index.d.ts
2626
declare function hello(): void;
2727
//#endregion
2828
export { hello as default };
2929
```
3030

31-
## index.js
31+
## index.mjs
3232

33-
```js
33+
```mjs
3434
//#region index.ts
3535
function hello() {
3636
console.log("Hello!");

tests/__snapshots__/clean/should-clean-custom-directories.snap.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## index.js
1+
## index.mjs
22

3-
```js
3+
```mjs
44
//#region index.ts
55
const hello = "world";
66

tests/__snapshots__/clean/should-clean-dist-directory-by-default.snap.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## index.js
1+
## index.mjs
22

3-
```js
3+
```mjs
44
//#region index.ts
55
const hello = "world";
66

tests/__snapshots__/clean/should-clean-files-with-specific-extensions.snap.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## index.js
1+
## index.mjs
22

3-
```js
3+
```mjs
44
//#region index.ts
55
const hello = "world";
66

tests/__snapshots__/clean/should-clean-multiple-patterns.snap.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## index.js
1+
## index.mjs
22

3-
```js
3+
```mjs
44
//#region index.ts
55
const hello = "world";
66

0 commit comments

Comments
 (0)