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 (
6969 defaultTransformSource ,
7070) {
7171 const { url } = context ;
72- const filePath = fileURLToPath ( url ) ;
72+ const filePath = url . startsWith ( 'file://' ) ? fileURLToPath ( url ) : url ;
7373
7474 if ( process . send ) {
7575 process . send ( {
Original file line number Diff line number Diff line change @@ -215,7 +215,7 @@ export const load: load = async function (
215215 return loaded ;
216216 }
217217
218- const filePath = fileURLToPath ( url ) ;
218+ const filePath = url . startsWith ( 'file://' ) ? fileURLToPath ( url ) : url ;
219219 const code = loaded . source . toString ( ) ;
220220
221221 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 = [
3838 import ( './specs/wasm' ) ,
3939 node ,
4040 ) ;
41+ runTestSuite (
42+ import ( './specs/data' ) ,
43+ node ,
44+ ) ;
4145 } ) ;
4246
4347 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