-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix shared chunk type file extension (#569)
- Loading branch information
Showing
8 changed files
with
73 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { readFileSync, promises as fsp } from 'fs' | ||
import { createIntegrationTest } from '../utils' | ||
import path from 'path' | ||
|
||
describe('integration shared-module-ts', () => { | ||
it('should contain correct type file path of shared chunks', async () => { | ||
await createIntegrationTest( | ||
{ | ||
directory: __dirname, | ||
}, | ||
async ({ distDir }) => { | ||
const files = await fsp.readdir(distDir) | ||
const sharedUtilModuleFile = files.find((file) => | ||
/util-shared-\w+\.d\.ts/.test(file), | ||
)! | ||
const appContextSharedFile = files.find((file) => | ||
/app-context-shared-\w+\.d\.ts/.test(file), | ||
)! | ||
|
||
const indexType = files.find((file) => file === 'index.d.ts')! | ||
const indexFileContent = readFileSync( | ||
path.join(distDir, indexType), | ||
'utf-8', | ||
) | ||
|
||
expect(indexFileContent).toContain( | ||
sharedUtilModuleFile.replace('.d.ts', '.js'), | ||
) | ||
expect(indexFileContent).toContain( | ||
appContextSharedFile.replace('.d.ts', '.js'), | ||
) | ||
}, | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"name": "shared-module", | ||
"type": "module", | ||
"exports": { | ||
".": { | ||
"types": "./dist/index.d.ts", | ||
"react-server": "./dist/index.react-server.js", | ||
"import": "./dist/index.js", | ||
"default": "./dist/index.cjs" | ||
}, | ||
"./another": { | ||
"types": "./dist/another.d.ts", | ||
"import": "./dist/another.js", | ||
"default": "./dist/another.cjs" | ||
} | ||
}, | ||
"dependencies": { | ||
"react": "*" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { sharedApi as anotherSharedApi } from './lib/util.shared-runtime' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { AppContext } from './lib/app-context.shared-runtime' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export const index = 'index' | ||
export { sharedApi } from './lib/util.shared-runtime' | ||
export { AppContext } from './lib/app-context.shared-runtime' |
5 changes: 5 additions & 0 deletions
5
test/integration/shared-module-ts/src/lib/app-context.shared-runtime.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
'use client' | ||
|
||
import React from 'react' | ||
|
||
export const AppContext = React.createContext(null) |
3 changes: 3 additions & 0 deletions
3
test/integration/shared-module-ts/src/lib/util.shared-runtime.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export function sharedApi() { | ||
return 'common:shared' | ||
} |