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

Parcel duplicates file that is imported in two different ways #8526

Open
bergwerf opened this issue Oct 6, 2022 · 2 comments
Open

Parcel duplicates file that is imported in two different ways #8526

bergwerf opened this issue Oct 6, 2022 · 2 comments

Comments

@bergwerf
Copy link

bergwerf commented Oct 6, 2022

🐛 bug report

I have one .ttf font file that I import both in TypeScript via import path from 'url:...' and in a CSS @font-face via src: url(...). Parcel outputs two copies of this file, with a different hash.

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

tsconfig.json

{
  "include": [
    "src/**/*",
    "web/**/*"
  ],
  "compilerOptions": {
    "target": "ES6",
    "strict": true
  }
}

.parcelrc

{
  "extends": "@parcel/config-default",
  "transformers": {
    "*.{ts,tsx}": ["@parcel/transformer-typescript-tsc"]
  }
}

🤔 Expected Behavior

One asset is included once in the output.

😯 Current Behavior

One asset is included twice in the output (as two identical files, but with a different hash).

@mischnic
Copy link
Member

Another example (not sure if it's the same root cause though):

import logo1 from "url:./logo.svg";
const logo2 = new URL('logo.svg', import.meta.url);

console.log(logo1, logo2)

yields 2 svg bundles.

@github-actions github-actions bot added the Stale Inactive issues label May 17, 2023
@mischnic mischnic removed the Stale Inactive issues label May 17, 2023
@parcel-bundler parcel-bundler deleted a comment from github-actions bot May 17, 2023
@holoduke
Copy link

holoduke commented Sep 6, 2023

When using service-workers there is also a duplication issue.
When i use new Url(image.png,import.meta) somewhere in a js file and include the same image in a seperate CSS file the generated service-worker.js contains an array with two duplication images. It throws an error
Uncaught (in promise) DOMException: Failed to execute 'addAll' on 'Cache': Cache.addAll(): duplicate requests
The files do have the same hash btw.

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

3 participants