Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Asset was skipped or not found #6892

Open
kkrizzz opened this issue Sep 8, 2021 · 13 comments
Open

Asset was skipped or not found #6892

kkrizzz opened this issue Sep 8, 2021 · 13 comments

Comments

@kkrizzz
Copy link

kkrizzz commented Sep 8, 2021

🐛 bug report

After upgraded to rc.0 and fixed bunch of errors and messages I see this message:
Asset was skipped or not found

🎛 Configuration (.babelrc, package.json, cli command)

my .parcelrc

{
  "extends": ["@parcel/config-default"],
  "reporters":  ["...", "parcel-reporter-static-files-copy"],
}

🤔 Expected Behavior

Building normally

😯 Current Behavior

$ NODE_ENV=production parcel build --target browser index.html
🚨 Build failed.

@parcel/packager-js: Asset was skipped or not found.

  AssertionError [ERR_ASSERTION]: Asset was skipped or not found.
  at ScopeHoistingPackager.getSymbolResolution (/Users/kriz/Projects/treenity-exp/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:714:29)
  at /Users/kriz/Projects/treenity-exp/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:818:31
  at Array.map (<anonymous>)
  at ScopeHoistingPackager.buildAssetPrelude (/Users/kriz/Projects/treenity-exp/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:817:37)
  at ScopeHoistingPackager.buildAsset (/Users/kriz/Projects/treenity-exp/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:382:48)
  at ScopeHoistingPackager.visitAsset (/Users/kriz/Projects/treenity-exp/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:341:17)
  at /Users/kriz/Projects/treenity-exp/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:438:38
  at String.replace (<anonymous>)
  at ScopeHoistingPackager.buildAsset (/Users/kriz/Projects/treenity-exp/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:404:19)
  at ScopeHoistingPackager.visitAsset (/Users/kriz/Projects/treenity-exp/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:341:17)

🔦 Context

💻 Code Sample

🌍 Your Environment

I think it is not relevant to environment

Software Version(s)
Parcel 2.0.0-rc.0
Node 14.16.1
npm/Yarn yarn 1.22.5
Operating System MacOS 10.15.7
@mischnic
Copy link
Member

mischnic commented Sep 8, 2021

Can you provide a code sample that reproduces the issue?

@danmarshall
Copy link
Contributor

I got the same error. I think it occurred because of a conditional require in a dependency? Still trying to create a minimal repro.

The workaround was to turn off scope hoisting.

Also, would ne nice if this exception included the name of the asset: https://github.com/parcel-bundler/parcel/blob/v2/packages/packagers/js/src/ScopeHoistingPackager.js#L786

@jensengar
Copy link

I just ran into this issue as well. I haven't dug into the issue, but I can confirm that add --no-scope-hoist as a cli option fixes the issue.

@levrik
Copy link

levrik commented Sep 21, 2021

Experiencing the same issue. Weirdly adding --no-scope-hoist didn't fix the problem although the scope hoister is mentioned in the stack trace 😕
I'll try to dig deeper.

@garthenweb
Copy link
Contributor

I run into a same issue with parcel@v2.0.0 and was able to hunt it down to a this code path:

    module.hot.accept('./reducers', () => {
      const nextRootReducer = require('./reducers').default;
      store.replaceReducer(nextRootReducer);
    });

Removing the line const nextRootReducer = require('./reducers').default; fixed it. './reducers' was imported using esm within the same file as well. The file containing the code is part of a dynamic imported file.

I tried to implement a simple reproducible repo but in a smaller code base it was still working without further issues. Someone has an idea how to find out more or what to look at? I unfortunately cannot share the original repository.

@mischnic
Copy link
Member

This is very hard to reproduce because it depends on the order that dependencies are resolved in and generally on the shape of the asset graph. One helpful thing might be that this error and non-reproducible builds (where the bundle contents and therefore size/hash change between runs) usually have the same root cause (= the bug that's causing this).

@MartinDawson
Copy link

For me this happens with parcel watch:build. parcel build works fine.

@MartinDawson
Copy link

@mischnic I've reproduced this error:

Parcel: "^2.0.1"
Node: v16.13.0
Yarn: v1.22.15
OS: Ubuntu 19.04

Repo: https://github.com/TrackTak/parcel-watch-error

How to reproduce:

  • run yarn.
  • run yarn watch:build

output:

🚨 Build failed.

@parcel/packager-js: Asset was skipped or not found.

  AssertionError [ERR_ASSERTION]: Asset was skipped or not found.
  at ScopeHoistingPackager.getSymbolResolution
  (/home/martin/Documents/parcel-error/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:716:29)
  at /home/martin/Documents/parcel-error/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:820:31
  at Array.map (<anonymous>)
  at ScopeHoistingPackager.buildAssetPrelude
  (/home/martin/Documents/parcel-error/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:819:37)
  at ScopeHoistingPackager.buildAsset (/home/martin/Documents/parcel-error/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:382:48)
  at ScopeHoistingPackager.visitAsset (/home/martin/Documents/parcel-error/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:341:17)
  at /home/martin/Documents/parcel-error/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:440:56
  at String.replace (<anonymous>)
  at ScopeHoistingPackager.buildAsset (/home/martin/Documents/parcel-error/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:404:19)
  at ScopeHoistingPackager.visitAsset (/home/martin/Documents/parcel-error/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:341:17)

@flexdinesh
Copy link

I'm running into the same error with parcel watch. parcel build builds successfully.

Repo reproducing the error — https://github.com/flexdinesh/parcel-react-watch-error

Node: v16.9.0
MacBook Air (M1, 2020)
macOS: Monterey 12.1

yarn run v1.22.11
$ parcel watch --cache-dir .parcel-cache
🚨 Build failed.

@parcel/packager-js: Asset was skipped or not found.

  AssertionError [ERR_ASSERTION]: Asset was skipped or not found.
  at ScopeHoistingPackager.getSymbolResolution
  (/Users/dineshpandiyan/workspace/parcel-react-watch-error/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:732:29)
  at
  /Users/dineshpandiyan/workspace/parcel-react-watch-error/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:836:31
  at Array.map (<anonymous>)
  at ScopeHoistingPackager.buildAssetPrelude
  (/Users/dineshpandiyan/workspace/parcel-react-watch-error/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:835:37)
  at ScopeHoistingPackager.buildAsset
  (/Users/dineshpandiyan/workspace/parcel-react-watch-error/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:398:48)
  at ScopeHoistingPackager.visitAsset
  (/Users/dineshpandiyan/workspace/parcel-react-watch-error/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:357:17)
  at
  /Users/dineshpandiyan/workspace/parcel-react-watch-error/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:456:56
  at String.replace (<anonymous>)
  at ScopeHoistingPackager.buildAsset
  (/Users/dineshpandiyan/workspace/parcel-react-watch-error/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:420:19)
  at ScopeHoistingPackager.visitAsset
  (/Users/dineshpandiyan/workspace/parcel-react-watch-error/node_modules/@parcel/packager-js/lib/ScopeHoistingPackager.js:357:17)

lettertwo added a commit that referenced this issue Apr 6, 2022
For library targets:
  - Skips applying refresh transforms in JSTransformer
  - Skips applying ReactRefreshRuntime
  - Skips applying transforms in ReactRefreshWrapTransformer
  - Adds test asserting that runtime and transforms are not applied

Fixes #7359, #7496, #7652, #7900
See also: #6892
devongovett pushed a commit that referenced this issue Apr 7, 2022
For library targets:
  - Skips applying refresh transforms in JSTransformer
  - Skips applying ReactRefreshRuntime
  - Skips applying transforms in ReactRefreshWrapTransformer
  - Adds test asserting that runtime and transforms are not applied

Fixes #7359, #7496, #7652, #7900
See also: #6892

Co-authored-by: Niklas Mischkulnig <4586894+mischnic@users.noreply.github.com>
@lettertwo
Copy link
Member

#7914 will solve this for React library cases (/cc @MartinDawson @flexdinesh).

There is still a more general problem that manifests as Asset was skipped or not found, which we will continue to track here.

@interstates21
Copy link

For me, this issue appears when I import crypto-js or crypto libraries

@mattcompiles
Copy link
Contributor

We ran into this issue and it was caused by two re-exports of the same file.

e.g.

export * from './events';

import * as _Events from "./events";
export { _Events as Events };

Removing one of the re-exports resolved the issue.

@mischnic
Copy link
Member

mischnic commented Jan 3, 2023

Full reproduction for that (the error isn't thrown but the asset is still excluded incorrectly and the output JS is invalid)

// index.js
import { c } from "./b.js";
console.log(c);

// b.js
export * from "./c.js";
import * as _a from "./c.js";
export { _a as c };

// c.js
export const a = 1;
export const b = 2;

// package.json
{
	"sideEffects": ["index.js"]
}

Output:

(() => {
	console.log((0, $c98c7015a51a9260$exports.c));
})();

Somewhat related: #5255

One possible solution is modelling export * from with some boolean property as opposed to a * -> * entry in the symbols map.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests