-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add alias replace externals tests in bundleless mode
- Loading branch information
1 parent
8a9f9e3
commit 3b63510
Showing
9 changed files
with
196 additions
and
26 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 |
---|---|---|
@@ -1,14 +1,41 @@ | ||
import { buildAndGetResults } from 'test-helper'; | ||
import { buildAndGetResults, queryContent } from 'test-helper'; | ||
import { expect, test } from 'vitest'; | ||
|
||
test('source.alias', async () => { | ||
const fixturePath = __dirname; | ||
const { entries } = await buildAndGetResults({ fixturePath }); | ||
const { contents } = await buildAndGetResults({ fixturePath }); | ||
|
||
expect(entries.esm).toContain('hello world'); | ||
expect(entries.cjs).toContain('hello world'); | ||
const { content: indexBundleEsmContent } = queryContent( | ||
contents.esm0!, | ||
/esm\/index\.js/, | ||
); | ||
const { content: indexBundleCjsContent } = queryContent( | ||
contents.cjs0!, | ||
/cjs\/index\.cjs/, | ||
); | ||
const { content: indexBundlelessEsmContent } = queryContent( | ||
contents.esm1!, | ||
/esm\/index\.js/, | ||
); | ||
const { content: indexBundlelessCjsContent } = queryContent( | ||
contents.cjs1!, | ||
/cjs\/index\.cjs/, | ||
); | ||
|
||
// simple artifacts check | ||
expect(entries.esm).toMatchSnapshot(); | ||
expect(entries.cjs).toMatchSnapshot(); | ||
// bundle mode | ||
expect(indexBundleEsmContent).toContain('hello world'); | ||
expect(indexBundleCjsContent).toContain('hello world'); | ||
|
||
// bundleless mode | ||
expect(indexBundlelessEsmContent).toContain( | ||
'import * as __WEBPACK_EXTERNAL_MODULE__a_js__ from "./a.js";', | ||
); | ||
expect(indexBundlelessCjsContent).toContain( | ||
'const external_a_cjs_namespaceObject = require("./a.cjs");', | ||
); | ||
|
||
expect(indexBundleEsmContent).toMatchSnapshot(); | ||
expect(indexBundleCjsContent).toMatchSnapshot(); | ||
expect(indexBundlelessEsmContent).toMatchSnapshot(); | ||
expect(indexBundlelessCjsContent).toMatchSnapshot(); | ||
}); |
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
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
--- | ||
overviewHeaders: [2, 3] | ||
--- | ||
|
||
# lib.redirect | ||
|
||
:::info | ||
|
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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
--- | ||
overviewHeaders: [2, 3] | ||
--- | ||
|
||
# lib.redirect | ||
|
||
:::info | ||
|
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