Skip to content

Commit 7a9dd36

Browse files
committed
Remove ./src/* export from public build
We only export the source directory so Jest and Rollup can access them during local development and at build time. The files don't exist in the public builds, so we don't need the export entry, either.
1 parent 5e02cac commit 7a9dd36

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

scripts/rollup/packaging.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ function filterOutEntrypoints(name) {
152152
let jsonPath = `build/node_modules/${name}/package.json`;
153153
let packageJSON = JSON.parse(readFileSync(jsonPath));
154154
let files = packageJSON.files;
155+
let exportsJSON = packageJSON.exports;
155156
if (!Array.isArray(files)) {
156157
throw new Error('expected all package.json files to contain a files field');
157158
}
@@ -181,7 +182,6 @@ function filterOutEntrypoints(name) {
181182
unlinkSync(`build/node_modules/${name}/${filename}`);
182183
changed = true;
183184
// Remove it from the exports field too if it exists.
184-
const exportsJSON = packageJSON.exports;
185185
if (exportsJSON) {
186186
if (filename === 'index.js') {
187187
delete exportsJSON['.'];
@@ -190,6 +190,15 @@ function filterOutEntrypoints(name) {
190190
}
191191
}
192192
}
193+
194+
// We only export the source directory so Jest and Rollup can access them
195+
// during local development and at build time. The files don't exist in the
196+
// public builds, so we don't need the export entry, either.
197+
const sourceWildcardExport = './src/*';
198+
if (exportsJSON && exportsJSON[sourceWildcardExport]) {
199+
delete exportsJSON[sourceWildcardExport];
200+
changed = true;
201+
}
193202
}
194203
if (changed) {
195204
let newJSON = JSON.stringify(packageJSON, null, ' ');

0 commit comments

Comments
 (0)