Skip to content

Commit 40ebdcd

Browse files
committed
Include all symbols in non-browser entries
1 parent ccd4d46 commit 40ebdcd

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

packages/core/core/src/AssetGraph.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ import nullthrows from 'nullthrows';
2929
import {ContentGraph} from '@parcel/graph';
3030
import {createDependency} from './Dependency';
3131
import {type ProjectPath, fromProjectPathRelative} from './projectPath';
32+
import {BROWSER_ENVS} from './public/Environment';
3233

3334
type InitOpts = {|
3435
entries?: Array<ProjectPath>,
@@ -223,6 +224,10 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
223224
correspondingRequest: string,
224225
) {
225226
let depNodes = targets.map(target => {
227+
// In library mode, all of the entry's symbols are "used"
228+
// In non-browser environments, exports may also be used (e.g. serverless request handlers).
229+
let includeAllSymbols =
230+
target.env.isLibrary || !BROWSER_ENVS.has(target.env.context);
226231
let node = nodeFromDep(
227232
// The passed project path is ignored in this case, because there is no `loc`
228233
createDependency('', {
@@ -233,14 +238,13 @@ export default class AssetGraph extends ContentGraph<AssetGraphNode> {
233238
env: target.env,
234239
isEntry: true,
235240
needsStableName: true,
236-
symbols: target.env.isLibrary
241+
symbols: includeAllSymbols
237242
? new Map([['*', {local: '*', isWeak: true, loc: null}]])
238243
: undefined,
239244
}),
240245
);
241246

242-
if (node.value.env.isLibrary) {
243-
// in library mode, all of the entry's symbols are "used"
247+
if (includeAllSymbols) {
244248
node.usedSymbolsDown.add('*');
245249
node.usedSymbolsUp.set('*', undefined);
246250
}

0 commit comments

Comments
 (0)