File tree Expand file tree Collapse file tree
turbopack-import-type-bytes
turbopack-import-type-text
turbopack-import-with-type Expand file tree Collapse file tree Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
Load Diff This file was deleted.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change 1+ import text from './data.txt' with { type : 'text' }
2+ import jsAsText from './some.js' with { type : 'text' }
3+ import bytes from './data.bin' with { type : 'bytes' }
4+ import jsAsBytes from './some.js' with { type : 'bytes' }
5+
6+ export async function GET ( _req ) {
7+ return Response . json (
8+ {
9+ text : {
10+ typeofString : typeof text === 'string' ,
11+ length : text . length ,
12+ content : text ,
13+ } ,
14+ jsAsText : {
15+ typeofString : typeof jsAsText === 'string' ,
16+ content : jsAsText ,
17+ } ,
18+ bytes : {
19+ instanceofUint8Array : bytes instanceof Uint8Array ,
20+ length : bytes . length ,
21+ content : new TextDecoder ( ) . decode ( bytes ) ,
22+ } ,
23+ jsAsBytes : {
24+ instanceofUint8Array : jsAsBytes instanceof Uint8Array ,
25+ content : new TextDecoder ( ) . decode ( jsAsBytes ) ,
26+ } ,
27+ } ,
28+ { status : 200 }
29+ )
30+ }
Original file line number Diff line number Diff line change 1+ export const nope = 'nope'
2+
3+ throw new Error ( 'please dont execute me' )
Original file line number Diff line number Diff line change 1+ import { nextTestSetup } from 'e2e-utils'
2+
3+ const jsContent = `export const nope = 'nope'
4+
5+ throw new Error('please dont execute me')
6+ `
7+
8+ describe ( 'turbopack-import-with-type' , ( ) => {
9+ const { next, skipped } = nextTestSetup ( {
10+ files : __dirname ,
11+ skipDeployment : true ,
12+ } )
13+
14+ if ( skipped ) {
15+ return
16+ }
17+
18+ // Testing this together on one route ensures we also avoid weird duplicate module ident things
19+ it ( 'supports import with type: text and type: bytes' , async ( ) => {
20+ const response = JSON . parse ( await next . render ( '/api' ) )
21+ expect ( response ) . toEqual ( {
22+ text : {
23+ typeofString : true ,
24+ length : 12 ,
25+ content : 'hello world\n' ,
26+ } ,
27+ jsAsText : {
28+ typeofString : true ,
29+ content : jsContent ,
30+ } ,
31+ bytes : {
32+ instanceofUint8Array : true ,
33+ length : 18 ,
34+ content : 'this is some data\n' ,
35+ } ,
36+ jsAsBytes : {
37+ instanceofUint8Array : true ,
38+ content : jsContent ,
39+ } ,
40+ } )
41+ } )
42+ } )
You can’t perform that action at this time.
0 commit comments