Plugins: import with relative and absolute path -> file appears two times in bundle.js

Created on 3 Apr 2020  ·  10Comments  ·  Source: rollup/plugins

  • Rollup Plugin Name: plugin-alias
  • Rollup Plugin Version: 3.0.1.0.2
  • Rollup Version: 1.32.1
  • Operating System (or Browser): Mac/Chrome
  • Node Version: 13.8.0

How Do We Reproduce?

if you include a file with a relative path:
import { file } from './file.js';
and somewhere else import it with an alias:
import { file } from 'alias/file.js';
the file appears two times in the bundle, one time as file and one time as file$1 and it also gets called two times. If I just use the relative path in both examples or the absolute path in both examples, the file appears there just one time and gets called just one time.

Expected Behavior

The js-import should just appear one time in the bundle.js and should not be called twice.

Actual Behavior

The imported js-file apperas twice in the bundle.js. One time as file and one time as file$1 and it gets called twice.

c³ ⋅ PR welcome t¹ 🐞 bug 🔌 plugin-alias

All 10 comments

Thanks for opening an issue. Citing the issue template:

Issues without minimal reproductions will be closed! Please provide one by:

  1. Using the REPL.it plugin reproduction template at https://repl.it/@rollup/rollup-plugin-repro
  2. Provide a minimal repository link (Read https://git.io/fNzHA for instructions).
    These may take more time to triage than the other options.
  3. Using the REPL at https://rollupjs.org/repl/

Please add a reproduction and we'll be happy to triage further.

Here is the reproduction:
https://repl.it/repls/SourYellowDataset

if you start
npm install
npm run dev

then the file public/build/bundle.js contains the following lines (the content of testLoadedTwice two times):

console.log('Hello!');
const testLoadedTwice = null;

console.log('Hello!');
const testLoadedTwice$1 = null;

Thanks

I have experienced this exact issue (details here) ... very interested in this resolution!

The severity of this issue will vary based on the application itself:

  1. Certainly in all cases, the bundle size will be bloated (with duplicate definitions).

  2. If the app relies on things like instanceof MyClass, it will be problematic.

  3. In my case, the severity escalates to making it unusable, because my domain object model is somewhat advanced, utilizing package managers that are registering meta information directly on the class definitions ... which cannot be reliably accessed with the duplicate definitions.

The work-around to this issue is to consistently use the same import type (either relative or absolute imports), and the duplicate class definitions disappeared. _For now, I chose to stop using the alias rollup plugin._

</Kevin>

Hey folks. This issue hasn't received any traction for more than 90 days, so we're going to close this for housekeeping. If this is still an ongoing issue, please do consider contributing a Pull Request to resolve it. Further discussion is always welcome even with the issue closed. If anything actionable is posted in the comments, we'll consider reopening it.

It doesn't seem appropriate to close a "known issue" simply for lack of "traction" :-(

I suspect more people are experiencing this issue without realizing it ... where the only symptom is a bloated bundle size _(see my severity comments above)_.

See: https://github.com/probot/stale#is-closing-stale-issues-really-a-good-idea

We've now setup the probot to handle this automatically, getting a lot of fatigue from explaining why this is done and folks not understanding how large repos are managed.

Please keep further discussion on topic of the issue details and not repo management.

When will this issue be opened again? It is still closed! This is a very important issue!

if it's very important to you, which we certainly don't minimize, please consider opening a pull request to address it, or rallying support from the community to resolve the issue.

@shellscape ... I did not intend to cast a "disparaging connotation" to you. I very much appreciate your contributions to the OSS community.

My only point was that in this particular case, this issue may deserve extra consideration. I believe this issue to be much broader scoped than the two individuals on this thread.

Developers may be experiencing this issue without realizing it, when the only artifact is a bloated bundle size! Please reread my original comment (above) dealing with severity levels and work-around.

Your help _(and consideration)_ is greatly appreciated :-)

Was this page helpful?
0 / 5 - 0 ratings