Skip to content

Commit a14f8d4

Browse files
fix: should glob dot files in bundleless mode (#1196)
Co-authored-by: Timeless0911 <[email protected]>
1 parent 1bced60 commit a14f8d4

File tree

14 files changed

+83
-10
lines changed

14 files changed

+83
-10
lines changed

packages/core/src/config.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1209,6 +1209,7 @@ const composeEntryConfig = async (
12091209
const globEntryFiles = await glob(entryFiles, {
12101210
cwd: root,
12111211
absolute: true,
1212+
dot: true,
12121213
});
12131214

12141215
// Filter the glob resolved entry files based on the allowed extensions
@@ -1347,7 +1348,11 @@ const composeBundlelessExternalConfig = (
13471348
// Requests that fall through here cannot be matched by any other externals config ahead.
13481349
// Treat all these requests as relative import of source code. Node.js won't add the
13491350
// leading './' to the relative path resolved by `path.relative`. So add manually it here.
1350-
if (resolvedRequest[0] !== '.') {
1351+
// should include dot files like '.hidden.ts'
1352+
if (
1353+
!resolvedRequest.startsWith('./') &&
1354+
!resolvedRequest.startsWith('../')
1355+
) {
13511356
resolvedRequest = `./${resolvedRequest}`;
13521357
}
13531358
return resolvedRequest;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const hiddenFolder = 'This is a hidden folder';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const hidden = 'This is a hidden file';

tests/integration/bundle-false/basic/src/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { mainFiles1 } from './mainFiles1';
2+
23
export { mainFiles1 };
4+
export * from './.hidden';
5+
export * from './.hidden-folder';
36
export { added } from './dep';
47

58
export * from './mainFiles2';

tests/integration/bundle-false/index.test.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ test('basic', async () => {
99
// ESM
1010
expect(files.esm).toMatchInlineSnapshot(`
1111
[
12+
"<ROOT>/tests/integration/bundle-false/basic/dist/esm/.hidden-folder/index.js",
13+
"<ROOT>/tests/integration/bundle-false/basic/dist/esm/.hidden.js",
1214
"<ROOT>/tests/integration/bundle-false/basic/dist/esm/dep.js",
1315
"<ROOT>/tests/integration/bundle-false/basic/dist/esm/index.js",
1416
"<ROOT>/tests/integration/bundle-false/basic/dist/esm/mainFiles1/index.js",
@@ -19,13 +21,13 @@ test('basic', async () => {
1921
]
2022
`);
2123

22-
const { path: esmIndexPath } = queryContent(contents.esm, 'index.js', {
23-
basename: true,
24-
});
24+
const { path: esmIndexPath } = queryContent(contents.esm, /esm\/index\.js/);
2525

2626
expect(await import(esmIndexPath)).toMatchInlineSnapshot(`
2727
{
2828
"added": 3,
29+
"hidden": "This is a hidden file",
30+
"hiddenFolder": "This is a hidden folder",
2931
"mainFiles1": "mainFiles1",
3032
"mainFiles2": "mainFiles2",
3133
"num1": 1,
@@ -39,9 +41,10 @@ test('basic', async () => {
3941
}
4042
`);
4143

42-
const { content: indexContent } = queryContent(contents.esm, 'index.js', {
43-
basename: true,
44-
});
44+
const { content: indexContent } = queryContent(
45+
contents.esm,
46+
/esm\/index\.js/,
47+
);
4548
const { content: depContent } = queryContent(contents.esm, 'dep.js', {
4649
basename: true,
4750
});
@@ -51,6 +54,8 @@ test('basic', async () => {
5154
expect(indexContent).toMatchInlineSnapshot(`
5255
"import { mainFiles1 } from "./mainFiles1/index.js";
5356
import { added } from "./dep.js";
57+
export * from "./.hidden.js";
58+
export * from "./.hidden-folder/index.js";
5459
export * from "./mainFiles2/index.js";
5560
export * from "./sum.js";
5661
export * from "./utils/numbers.js";
@@ -76,6 +81,8 @@ test('basic', async () => {
7681
// CJS
7782
expect(files.cjs).toMatchInlineSnapshot(`
7883
[
84+
"<ROOT>/tests/integration/bundle-false/basic/dist/cjs/.hidden-folder/index.cjs",
85+
"<ROOT>/tests/integration/bundle-false/basic/dist/cjs/.hidden.cjs",
7986
"<ROOT>/tests/integration/bundle-false/basic/dist/cjs/dep.cjs",
8087
"<ROOT>/tests/integration/bundle-false/basic/dist/cjs/index.cjs",
8188
"<ROOT>/tests/integration/bundle-false/basic/dist/cjs/mainFiles1/index.cjs",
@@ -86,13 +93,13 @@ test('basic', async () => {
8693
]
8794
`);
8895

89-
const { path: cjsIndexPath } = queryContent(contents.cjs, 'index.cjs', {
90-
basename: true,
91-
});
96+
const { path: cjsIndexPath } = queryContent(contents.cjs, /cjs\/index\.cjs/);
9297

9398
expect((await import(cjsIndexPath)).default).toMatchInlineSnapshot(`
9499
{
95100
"added": 3,
101+
"hidden": "This is a hidden file",
102+
"hiddenFolder": "This is a hidden folder",
96103
"mainFiles1": "mainFiles1",
97104
"mainFiles2": "mainFiles2",
98105
"num1": 1,

tests/integration/redirect/dts.test.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ beforeAll(async () => {
1212
test('redirect.dts.path: true with redirect.dts.extension: false - default', async () => {
1313
expect(contents.esm0).toMatchInlineSnapshot(`
1414
{
15+
"<ROOT>/tests/integration/redirect/dts/dist/default/esm/.hidden-folder/index.d.ts": "export declare const hiddenFolder = "This is a hidden folder";
16+
",
17+
"<ROOT>/tests/integration/redirect/dts/dist/default/esm/.hidden.d.ts": "export declare const hidden = "This is a hidden file";
18+
",
1519
"<ROOT>/tests/integration/redirect/dts/dist/default/esm/a.b/index.d.ts": "export declare const ab = "a.b";
1620
",
1721
"<ROOT>/tests/integration/redirect/dts/dist/default/esm/bar.baz.d.ts": "export declare const bar = "bar-baz";
@@ -36,6 +40,8 @@ test('redirect.dts.path: true with redirect.dts.extension: false - default', asy
3640
export { Router } from 'express';
3741
export * from '../../../compile/prebundle-pkg';
3842
export type { Bar } from './types';
43+
export * from './.hidden';
44+
export * from './.hidden-folder';
3945
export * from './a.b';
4046
export * from './bar.baz';
4147
export * from './foo';
@@ -67,6 +73,10 @@ test('redirect.dts.path: true with redirect.dts.extension: false - default', asy
6773
test('redirect.dts.path: false with redirect.dts.extension: false', async () => {
6874
expect(contents.esm1).toMatchInlineSnapshot(`
6975
{
76+
"<ROOT>/tests/integration/redirect/dts/dist/path-false/esm/.hidden-folder/index.d.ts": "export declare const hiddenFolder = "This is a hidden folder";
77+
",
78+
"<ROOT>/tests/integration/redirect/dts/dist/path-false/esm/.hidden.d.ts": "export declare const hidden = "This is a hidden file";
79+
",
7080
"<ROOT>/tests/integration/redirect/dts/dist/path-false/esm/a.b/index.d.ts": "export declare const ab = "a.b";
7181
",
7282
"<ROOT>/tests/integration/redirect/dts/dist/path-false/esm/bar.baz.d.ts": "export declare const bar = "bar-baz";
@@ -91,6 +101,8 @@ test('redirect.dts.path: false with redirect.dts.extension: false', async () =>
91101
export { Router } from 'express';
92102
export * from 'prebundle-pkg';
93103
export type { Bar } from 'types';
104+
export * from './.hidden';
105+
export * from './.hidden-folder';
94106
export * from './a.b';
95107
export * from './bar.baz';
96108
export * from './foo';
@@ -122,6 +134,10 @@ test('redirect.dts.path: false with redirect.dts.extension: false', async () =>
122134
test('redirect.dts.path: true with redirect.dts.extension: true', async () => {
123135
expect(contents.esm2).toMatchInlineSnapshot(`
124136
{
137+
"<ROOT>/tests/integration/redirect/dts/dist/extension-true/esm/.hidden-folder/index.d.ts": "export declare const hiddenFolder = "This is a hidden folder";
138+
",
139+
"<ROOT>/tests/integration/redirect/dts/dist/extension-true/esm/.hidden.d.ts": "export declare const hidden = "This is a hidden file";
140+
",
125141
"<ROOT>/tests/integration/redirect/dts/dist/extension-true/esm/a.b/index.d.ts": "export declare const ab = "a.b";
126142
",
127143
"<ROOT>/tests/integration/redirect/dts/dist/extension-true/esm/bar.baz.d.ts": "export declare const bar = "bar-baz";
@@ -146,6 +162,8 @@ test('redirect.dts.path: true with redirect.dts.extension: true', async () => {
146162
export { Router } from 'express';
147163
export * from '../../../compile/prebundle-pkg';
148164
export type { Bar } from './types.js';
165+
export * from './.hidden.js';
166+
export * from './.hidden-folder/index.js';
149167
export * from './a.b/index.js';
150168
export * from './bar.baz.js';
151169
export * from './foo/index.js';
@@ -177,6 +195,10 @@ test('redirect.dts.path: true with redirect.dts.extension: true', async () => {
177195
test('redirect.dts.path: false with dts.redirect.extension: true', async () => {
178196
expect(contents.esm3).toMatchInlineSnapshot(`
179197
{
198+
"<ROOT>/tests/integration/redirect/dts/dist/path-false-extension-true/esm/.hidden-folder/index.d.ts": "export declare const hiddenFolder = "This is a hidden folder";
199+
",
200+
"<ROOT>/tests/integration/redirect/dts/dist/path-false-extension-true/esm/.hidden.d.ts": "export declare const hidden = "This is a hidden file";
201+
",
180202
"<ROOT>/tests/integration/redirect/dts/dist/path-false-extension-true/esm/a.b/index.d.ts": "export declare const ab = "a.b";
181203
",
182204
"<ROOT>/tests/integration/redirect/dts/dist/path-false-extension-true/esm/bar.baz.d.ts": "export declare const bar = "bar-baz";
@@ -201,6 +223,8 @@ test('redirect.dts.path: false with dts.redirect.extension: true', async () => {
201223
export { Router } from 'express';
202224
export * from 'prebundle-pkg';
203225
export type { Bar } from 'types';
226+
export * from './.hidden.js';
227+
export * from './.hidden-folder/index.js';
204228
export * from './a.b/index.js';
205229
export * from './bar.baz.js';
206230
export * from './foo/index.js';
@@ -232,6 +256,14 @@ test('redirect.dts.path: false with dts.redirect.extension: true', async () => {
232256
test('redirect.dts.extension: true with dts.autoExtension: true', async () => {
233257
expect(contents.esm4).toMatchInlineSnapshot(`
234258
{
259+
"<ROOT>/tests/integration/redirect/dts/dist/auto-extension-true/.hidden-folder/index.d.mts": "export declare const hiddenFolder = "This is a hidden folder";
260+
",
261+
"<ROOT>/tests/integration/redirect/dts/dist/auto-extension-true/.hidden-folder/index.d.ts": "export declare const hiddenFolder = "This is a hidden folder";
262+
",
263+
"<ROOT>/tests/integration/redirect/dts/dist/auto-extension-true/.hidden.d.mts": "export declare const hidden = "This is a hidden file";
264+
",
265+
"<ROOT>/tests/integration/redirect/dts/dist/auto-extension-true/.hidden.d.ts": "export declare const hidden = "This is a hidden file";
266+
",
235267
"<ROOT>/tests/integration/redirect/dts/dist/auto-extension-true/a.b/index.d.mts": "export declare const ab = "a.b";
236268
",
237269
"<ROOT>/tests/integration/redirect/dts/dist/auto-extension-true/a.b/index.d.ts": "export declare const ab = "a.b";
@@ -267,6 +299,8 @@ test('redirect.dts.extension: true with dts.autoExtension: true', async () => {
267299
export { Router } from 'express';
268300
export * from '../../compile/prebundle-pkg';
269301
export type { Bar } from './types.mjs';
302+
export * from './.hidden.mjs';
303+
export * from './.hidden-folder/index.mjs';
270304
export * from './a.b/index.mjs';
271305
export * from './bar.baz.mjs';
272306
export * from './foo/index.mjs';
@@ -285,6 +319,8 @@ test('redirect.dts.extension: true with dts.autoExtension: true', async () => {
285319
export { Router } from 'express';
286320
export * from '../../compile/prebundle-pkg';
287321
export type { Bar } from './types.js';
322+
export * from './.hidden.js';
323+
export * from './.hidden-folder/index.js';
288324
export * from './a.b/index.js';
289325
export * from './bar.baz.js';
290326
export * from './foo/index.js';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const hiddenFolder = 'This is a hidden folder';
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const hidden = 'This is a hidden file';

tests/integration/redirect/dts/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export type { Foo } from '@src/types';
2121
export { Router } from 'express';
2222
export * from 'prebundle-pkg';
2323
export type { Bar } from 'types';
24+
export * from './.hidden';
25+
export * from './.hidden-folder';
2426
export * from './a.b';
2527
export * from './bar.baz';
2628
export * from './foo';

tests/integration/redirect/js.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ test('redirect.js default', async () => {
2626
import { bar } from "./bar/index.js";
2727
import { foo } from "./foo.js";
2828
import { baz } from "./baz.js";
29+
export * from "./.hidden.js";
30+
export * from "./.hidden-folder/index.js";
2931
const src = lodash.toUpper(lodash_merge(foo) + bar + foo + bar + baz + typeof prettier.version);
3032
export { src as default };
3133
"
@@ -53,6 +55,8 @@ test('redirect.js.path false', async () => {
5355
import { baz } from "~/baz";
5456
import { bar as external_bar_js_bar } from "./bar.js";
5557
import { foo as external_foo_js_foo } from "./foo.js";
58+
export * from "./.hidden.js";
59+
export * from "./.hidden-folder.js";
5660
const src = lodash.toUpper(lodash_merge(external_foo_js_foo) + external_bar_js_bar + foo + bar + baz + typeof prettier.version);
5761
export { src as default };
5862
"
@@ -78,6 +82,8 @@ test('redirect.js.path with user override externals', async () => {
7882
import { baz } from "./baz.js";
7983
import { bar as index_js_bar } from "./bar/index.js";
8084
import { foo as external_foo_js_foo } from "./foo.js";
85+
export * from "./.hidden.js";
86+
export * from "./.hidden-folder/index.js";
8187
const src = lodash.toUpper(lodash_merge(external_foo_js_foo) + index_js_bar + foo + bar + baz + typeof prettier.version);
8288
export { src as default };
8389
"
@@ -111,6 +117,8 @@ test('redirect.js.path with user override alias', async () => {
111117
import { baz } from "./baz.js";
112118
import { bar as index_js_bar } from "./bar/index.js";
113119
import { foo as external_foo_js_foo } from "./foo.js";
120+
export * from "./.hidden.js";
121+
export * from "./.hidden-folder/index.js";
114122
const src = lodash.toUpper(lodash_merge(external_foo_js_foo) + index_js_bar + foo + bar + baz + typeof prettier.version);
115123
export { src as default };
116124
"
@@ -137,6 +145,8 @@ test('redirect.js.extension: false', async () => {
137145
import { bar } from "./bar/index.ts";
138146
import { foo } from "./foo.ts";
139147
import { baz } from "./baz.ts";
148+
export * from "./.hidden.ts";
149+
export * from "./.hidden-folder/index.ts";
140150
const src = lodash.toUpper(lodash_merge(foo) + bar + foo + bar + baz + typeof prettier.version);
141151
export { src as default };
142152
"

0 commit comments

Comments
 (0)