feat(rust): remove unused import(..) if importee doesn't have side-effects#3598
Closed
shulaoda wants to merge 3 commits into
Closed
feat(rust): remove unused import(..) if importee doesn't have side-effects#3598shulaoda wants to merge 3 commits into
import(..) if importee doesn't have side-effects#3598shulaoda wants to merge 3 commits into
Conversation
import(..) if importee doesn't have side-effectsimport(..) if importee doesn't have side-effects
✅ Deploy Preview for rolldown-rs canceled.
|
import(..) if importee doesn't have side-effectsimport(..) if importee doesn't have side-effects
shulaoda
force-pushed
the
feat/remove-unused-import
branch
4 times, most recently
from
February 16, 2025 22:37
c3c25eb to
96bf7bf
Compare
shulaoda
marked this pull request as draft
February 16, 2025 22:53
shulaoda
marked this pull request as ready for review
February 16, 2025 22:57
shulaoda
marked this pull request as draft
February 16, 2025 23:57
shulaoda
marked this pull request as draft
February 16, 2025 23:57
shulaoda
commented
Feb 17, 2025
Comment on lines
+43
to
+46
| var __dynamicEmptyModule = Object.freeze({ | ||
| __proto__: null, | ||
| default: {} | ||
| }); |
Member
Author
There was a problem hiding this comment.
__DynamicEmptyModule may not be good because there may be the following situations:
let a = await('./a.js')
let b = await('./b.js')
console.log(a == b)
Member
Author
There was a problem hiding this comment.
We should align with rollup and let me continue to improve.
Member
Author
There was a problem hiding this comment.
It is difficult to achieve functions similar to rollup.
// entry.js
import('./abc.js')
import('./dynamic.js').then(() => console.log("1"))
// abc.js
import('./dynamic.js').then(() => console.log("2"))
// dynamic.jsThe current implementation result is:
// entry.js
import "./entry--jpnM2Ll.js";
// entry--jpnM2Ll.js
import("./abc-BIQEauab.js");
Promise.resolve().then(function() {
return dynamic;
}).then(() => console.log("1"));
var dynamic = Object.freeze({
__proto__: null,
default: {}
});
export { dynamic };
// abc-BIQEauab.js
import { dynamic } from "./entry--jpnM2Ll.js";
Promise.resolve().then(function() {
return dynamic;
}).then(() => console.log("2"));Rollup:
// entry.js
import('./abc-qNCBTG9J.js');
Promise.resolve().then(function () { return dynamic; }).then(() => console.log("1"));
var dynamic = /*#__PURE__*/Object.freeze({
__proto__: null
});
export { dynamic as d };
// abc-qNCBTG9J.js
import('./main.js').then(function (n) { return n.d; });
shulaoda
force-pushed
the
feat/remove-unused-import
branch
from
February 20, 2025 00:39
96bf7bf to
1521a76
Compare
github-merge-queue Bot
pushed a commit
that referenced
this pull request
Mar 20, 2025
…#3911) <!-- Thank you for contributing! --> ### Description 1. Closed #2827, closed #3598 2. I need to add `console.log` or some module in tests will be broken since the dynamic module is side effects free. <!-- Please insert your description here and provide especially info about the "what" this PR is solving -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
closes #2827
The core idea is that if a dynamic import module has no included statements and is not referenced, it‘s
module.is_included()should befalse.I’m facing an issue with how to implement the polyfill.There are two options: one is to declarevar init_foo = Object.freeze(..)at theimporterside, and the other is to introduce a global empty dynamic module (runtime).I'm constantly unable to correctly link the symbol reference forinit_fooor__dynamicEmpty. I’m unsure how to proceed correctly, so I’m just sharing my thoughts and seeking help on this.