This repository was archived by the owner on Oct 18, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 5 files changed +24
-2
lines changed
fixtures/package-module/lib/data Expand file tree Collapse file tree 5 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ const _transformSource: transformSource = async function (
69
69
defaultTransformSource ,
70
70
) {
71
71
const { url } = context ;
72
- const filePath = fileURLToPath ( url ) ;
72
+ const filePath = url . startsWith ( 'file://' ) ? fileURLToPath ( url ) : url ;
73
73
74
74
if ( process . send ) {
75
75
process . send ( {
Original file line number Diff line number Diff line change @@ -215,7 +215,7 @@ export const load: load = async function (
215
215
return loaded ;
216
216
}
217
217
218
- const filePath = fileURLToPath ( url ) ;
218
+ const filePath = url . startsWith ( 'file://' ) ? fileURLToPath ( url ) : url ;
219
219
const code = loaded . source . toString ( ) ;
220
220
221
221
if (
Original file line number Diff line number Diff line change
1
+ const base64Module = ( code ) => `data:text/javascript;base64,${ Buffer . from ( code ) . toString ( 'base64' ) } ` ;
2
+ const dataUrl = base64Module ( 'console.log(123)' ) ;
3
+ import ( dataUrl ) ;
Original file line number Diff line number Diff line change @@ -38,6 +38,10 @@ const nodeVersions = [
38
38
import ( './specs/wasm' ) ,
39
39
node ,
40
40
) ;
41
+ runTestSuite (
42
+ import ( './specs/data' ) ,
43
+ node ,
44
+ ) ;
41
45
} ) ;
42
46
43
47
runTestSuite (
Original file line number Diff line number Diff line change
1
+ import { testSuite , expect } from 'manten' ;
2
+ import type { NodeApis } from '../utils/node-with-loader' ;
3
+
4
+ export default testSuite ( async ( { describe } , node : NodeApis ) => {
5
+ describe ( 'data' , async ( { test } ) => {
6
+ const importPath = './lib/data/index.js' ;
7
+
8
+ test ( 'Loads text/javascript data URLs' , async ( ) => {
9
+ const nodeProcess = await node . load ( importPath ) ;
10
+
11
+ expect ( nodeProcess . exitCode ) . toBe ( 0 ) ;
12
+ expect ( nodeProcess . stdout ) . toMatch ( '123' ) ;
13
+ } ) ;
14
+ } ) ;
15
+ } ) ;
You can’t perform that action at this time.
0 commit comments