@@ -3,7 +3,7 @@ import path from 'node:path';
3
3
import process from 'node:process' ;
4
4
import { pathToFileURL } from 'node:url' ;
5
5
import * as rollup from '../../src/node-entry' ;
6
- import type { MergedRollupOptions } from '../../src/rollup/types' ;
6
+ import type { ImportAttributesKey , MergedRollupOptions } from '../../src/rollup/types' ;
7
7
import { bold } from '../../src/utils/colors' ;
8
8
import {
9
9
error ,
@@ -90,11 +90,16 @@ function getDefaultFromCjs(namespace: GenericConfigObject): unknown {
90
90
return namespace . default || namespace ;
91
91
}
92
92
93
+ function getConfigImportAttributesKey ( input : unknown ) : ImportAttributesKey | undefined {
94
+ if ( input === 'assert' || input === 'with' ) return input ;
95
+ return ;
96
+ }
97
+
93
98
async function loadTranspiledConfigFile (
94
99
fileName : string ,
95
100
commandOptions : Record < string , unknown >
96
101
) : Promise < unknown > {
97
- const { bundleConfigAsCjs, configPlugin, silent } = commandOptions ;
102
+ const { bundleConfigAsCjs, configPlugin, configImportAttributesKey , silent } = commandOptions ;
98
103
const warnings = batchWarnings ( commandOptions ) ;
99
104
const inputOptions = {
100
105
external : ( id : string ) => ( id [ 0 ] !== '.' && ! path . isAbsolute ( id ) ) || id . slice ( - 5 ) === '.json' ,
@@ -110,6 +115,7 @@ async function loadTranspiledConfigFile(
110
115
} = await bundle . generate ( {
111
116
exports : 'named' ,
112
117
format : bundleConfigAsCjs ? 'cjs' : 'es' ,
118
+ importAttributesKey : getConfigImportAttributesKey ( configImportAttributesKey ) ,
113
119
plugins : [
114
120
{
115
121
name : 'transpile-import-meta' ,
0 commit comments