diff --git a/e2e/README.md b/e2e/README.md index d5b31e556..b28a14804 100644 --- a/e2e/README.md +++ b/e2e/README.md @@ -24,10 +24,10 @@ Rslib will try to cover the common scenarios in the [integration test cases of M | esbuildOptions | ⚫️ | | | externals | 🟢 | | | format | 🟡 | Support `cjs` and `esm`, `umd` still need to be tested | -| input | ⚪️ | | +| input | 🟢 | | | jsx | ⚪️ | | | metafile | ⚪️ | | -| minify | ⚪️ | | +| minify | 🟢 | | | platform | 🟢 | | | redirect | ⚪️ | | | resolve | ⚪️ | | diff --git a/e2e/cases/entry/glob/package.json b/e2e/cases/entry/glob/package.json new file mode 100644 index 000000000..d6fc8733e --- /dev/null +++ b/e2e/cases/entry/glob/package.json @@ -0,0 +1,6 @@ +{ + "name": "entry-glob-test", + "version": "1.0.0", + "private": true, + "type": "module" +} diff --git a/e2e/cases/entry/glob/rslib.config.ts b/e2e/cases/entry/glob/rslib.config.ts new file mode 100644 index 000000000..38bd7e533 --- /dev/null +++ b/e2e/cases/entry/glob/rslib.config.ts @@ -0,0 +1,18 @@ +import { generateBundleCjsConfig, generateBundleEsmConfig } from '@e2e/helper'; +import { defineConfig } from '@rslib/core'; + +export default defineConfig({ + lib: [ + generateBundleEsmConfig({ + bundle: false, + }), + generateBundleCjsConfig({ + bundle: false, + }), + ], + source: { + entry: { + index: ['./src/**', '!**/*.ignore.ts'], + }, + }, +}); diff --git a/e2e/cases/entry/glob/src/bar.ts b/e2e/cases/entry/glob/src/bar.ts new file mode 100644 index 000000000..c0d6c241d --- /dev/null +++ b/e2e/cases/entry/glob/src/bar.ts @@ -0,0 +1,2 @@ +const bar = 'bar'; +console.log('bar: ', bar); diff --git a/e2e/cases/entry/glob/src/foo.ts b/e2e/cases/entry/glob/src/foo.ts new file mode 100644 index 000000000..3329a7d97 --- /dev/null +++ b/e2e/cases/entry/glob/src/foo.ts @@ -0,0 +1 @@ +export const foo = 'foo'; diff --git a/e2e/cases/entry/glob/src/ignore/baz.ignore.ts b/e2e/cases/entry/glob/src/ignore/baz.ignore.ts new file mode 100644 index 000000000..81c321aad --- /dev/null +++ b/e2e/cases/entry/glob/src/ignore/baz.ignore.ts @@ -0,0 +1,3 @@ +export default function () { + return 'ignore baz'; +} diff --git a/e2e/cases/entry/glob/src/index.ignore.ts b/e2e/cases/entry/glob/src/index.ignore.ts new file mode 100644 index 000000000..e96b7dd51 --- /dev/null +++ b/e2e/cases/entry/glob/src/index.ignore.ts @@ -0,0 +1,3 @@ +export default function () { + return 'ignore index'; +} diff --git a/e2e/cases/entry/glob/src/index.ts b/e2e/cases/entry/glob/src/index.ts new file mode 100644 index 000000000..3c8dc405f --- /dev/null +++ b/e2e/cases/entry/glob/src/index.ts @@ -0,0 +1,3 @@ +import { foo } from './foo'; + +export const text = () => `hello ${foo}`; diff --git a/e2e/cases/entry/index.test.ts b/e2e/cases/entry/index.test.ts new file mode 100644 index 000000000..d14c42880 --- /dev/null +++ b/e2e/cases/entry/index.test.ts @@ -0,0 +1,57 @@ +import { join } from 'node:path'; +import { buildAndGetResults } from '@e2e/helper'; +import { expect, test } from 'vitest'; + +test('single entry bundle', async () => { + const fixturePath = join(__dirname, 'single'); + const { files } = await buildAndGetResults(fixturePath); + + expect(files).toMatchInlineSnapshot(` + { + "cjs": [ + "/e2e/cases/entry/single/dist/cjs/index.cjs", + ], + "esm": [ + "/e2e/cases/entry/single/dist/esm/index.js", + ], + } + `); +}); + +test('multiple entry bundle', async () => { + const fixturePath = join(__dirname, 'multiple'); + const { files } = await buildAndGetResults(fixturePath); + + expect(files).toMatchInlineSnapshot(` + { + "cjs": [ + "/e2e/cases/entry/multiple/dist/cjs/bar.cjs", + "/e2e/cases/entry/multiple/dist/cjs/index.cjs", + ], + "esm": [ + "/e2e/cases/entry/multiple/dist/esm/bar.js", + "/e2e/cases/entry/multiple/dist/esm/index.js", + ], + } + `); +}); + +test('glob entry bundleless', async () => { + const fixturePath = join(__dirname, 'glob'); + const { files } = await buildAndGetResults(fixturePath); + + expect(files).toMatchInlineSnapshot(` + { + "cjs": [ + "/e2e/cases/entry/glob/dist/cjs/bar.cjs", + "/e2e/cases/entry/glob/dist/cjs/foo.cjs", + "/e2e/cases/entry/glob/dist/cjs/index.cjs", + ], + "esm": [ + "/e2e/cases/entry/glob/dist/esm/bar.js", + "/e2e/cases/entry/glob/dist/esm/foo.js", + "/e2e/cases/entry/glob/dist/esm/index.js", + ], + } + `); +}); diff --git a/e2e/cases/entry/multiple/package.json b/e2e/cases/entry/multiple/package.json new file mode 100644 index 000000000..8f525639b --- /dev/null +++ b/e2e/cases/entry/multiple/package.json @@ -0,0 +1,6 @@ +{ + "name": "entry-multiple-test", + "version": "1.0.0", + "private": true, + "type": "module" +} diff --git a/e2e/cases/entry/multiple/rslib.config.ts b/e2e/cases/entry/multiple/rslib.config.ts new file mode 100644 index 000000000..077ddd9e0 --- /dev/null +++ b/e2e/cases/entry/multiple/rslib.config.ts @@ -0,0 +1,12 @@ +import { generateBundleCjsConfig, generateBundleEsmConfig } from '@e2e/helper'; +import { defineConfig } from '@rslib/core'; + +export default defineConfig({ + lib: [generateBundleEsmConfig(), generateBundleCjsConfig()], + source: { + entry: { + index: ['./src/index.ts'], + bar: ['./src/bar.ts'], + }, + }, +}); diff --git a/e2e/cases/entry/multiple/src/bar.ts b/e2e/cases/entry/multiple/src/bar.ts new file mode 100644 index 000000000..9f1738685 --- /dev/null +++ b/e2e/cases/entry/multiple/src/bar.ts @@ -0,0 +1 @@ +export const bar = 'bar'; diff --git a/e2e/cases/entry/multiple/src/foo.ts b/e2e/cases/entry/multiple/src/foo.ts new file mode 100644 index 000000000..3329a7d97 --- /dev/null +++ b/e2e/cases/entry/multiple/src/foo.ts @@ -0,0 +1 @@ +export const foo = 'foo'; diff --git a/e2e/cases/entry/multiple/src/index.ts b/e2e/cases/entry/multiple/src/index.ts new file mode 100644 index 000000000..3c8dc405f --- /dev/null +++ b/e2e/cases/entry/multiple/src/index.ts @@ -0,0 +1,3 @@ +import { foo } from './foo'; + +export const text = () => `hello ${foo}`; diff --git a/e2e/cases/entry/single/package.json b/e2e/cases/entry/single/package.json new file mode 100644 index 000000000..159f13639 --- /dev/null +++ b/e2e/cases/entry/single/package.json @@ -0,0 +1,6 @@ +{ + "name": "entry-single-test", + "version": "1.0.0", + "private": true, + "type": "module" +} diff --git a/e2e/cases/entry/single/rslib.config.ts b/e2e/cases/entry/single/rslib.config.ts new file mode 100644 index 000000000..3cac7018f --- /dev/null +++ b/e2e/cases/entry/single/rslib.config.ts @@ -0,0 +1,11 @@ +import { generateBundleCjsConfig, generateBundleEsmConfig } from '@e2e/helper'; +import { defineConfig } from '@rslib/core'; + +export default defineConfig({ + lib: [generateBundleEsmConfig(), generateBundleCjsConfig()], + source: { + entry: { + index: './src/index.ts', + }, + }, +}); diff --git a/e2e/cases/entry/single/src/foo.ts b/e2e/cases/entry/single/src/foo.ts new file mode 100644 index 000000000..3329a7d97 --- /dev/null +++ b/e2e/cases/entry/single/src/foo.ts @@ -0,0 +1 @@ +export const foo = 'foo'; diff --git a/e2e/cases/entry/single/src/index.ts b/e2e/cases/entry/single/src/index.ts new file mode 100644 index 000000000..3c8dc405f --- /dev/null +++ b/e2e/cases/entry/single/src/index.ts @@ -0,0 +1,3 @@ +import { foo } from './foo'; + +export const text = () => `hello ${foo}`; diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 036250002..6673b0ef0 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -182,6 +182,12 @@ importers: e2e/cases/dts/bundle/false: {} + e2e/cases/entry/glob: {} + + e2e/cases/entry/multiple: {} + + e2e/cases/entry/single: {} + e2e/cases/extension-alias: {} e2e/cases/externals/browser: {}