@@ -5,6 +5,7 @@ import op from "node:path";
5
5
import { extname , join } from "node:path/posix" ;
6
6
import { pathToFileURL } from "node:url" ;
7
7
import commonjs from "@rollup/plugin-commonjs" ;
8
+ import json from "@rollup/plugin-json" ;
8
9
import { nodeResolve } from "@rollup/plugin-node-resolve" ;
9
10
import virtual from "@rollup/plugin-virtual" ;
10
11
import { packageDirectory } from "pkg-dir" ;
@@ -101,7 +102,11 @@ async function bundle(
101
102
...( isBadCommonJs ( input ) ? [ ( virtual as any ) ( { "-" : shimCommonJs ( input , require ) } ) ] : [ ] ) ,
102
103
importResolve ( input , cacheRoot , packageRoot ) ,
103
104
nodeResolve ( { browser : true , rootDir : packageRoot } ) ,
104
- ( commonjs as any ) ( { esmExternals : true } ) ,
105
+ ( json as any ) ( ) ,
106
+ ( commonjs as any ) ( {
107
+ esmExternals : true ,
108
+ requireReturnsDefault : "preferred"
109
+ } ) ,
105
110
esbuild ( {
106
111
format : "esm" ,
107
112
platform : "browser" ,
@@ -133,7 +138,7 @@ function importResolve(input: string, cacheRoot: string, packageRoot: string): P
133
138
return typeof specifier !== "string" || // AST node?
134
139
isNodeBuiltin ( specifier ) || // node built-in, e.g., "node:fs" or "fs"
135
140
isPathImport ( specifier ) || // relative path, e.g., ./foo.js
136
- / ^ \w + : / . test ( specifier ) || // windows file path, https: URL, etc.
141
+ / ^ \0 ? [ \w - ] + : / . test ( specifier ) || // windows file path, https: URL, \x00node-resolve: , etc.
137
142
specifier === input // entry point
138
143
? null // don’t do any additional resolution
139
144
: { id : await resolveNodeImportInternal ( cacheRoot , packageRoot , specifier ) , external : true } ; // resolve bare import
0 commit comments