GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Remove ./src/* export from public build (#23262) · react/react@1760b27

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • scripts/rollup
    • packaging.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎scripts/rollup/packaging.js‎

Copy file name to clipboardExpand all lines: scripts/rollup/packaging.js
+10-1Lines 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 (0)
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.