Skip to content

Commit

Permalink
feat: generate cross chunk imports by usages
Browse files Browse the repository at this point in the history
  • Loading branch information
hyf0 committed Feb 19, 2024
1 parent 4f77873 commit d9ccdb7
Show file tree
Hide file tree
Showing 77 changed files with 24 additions and 138 deletions.
3 changes: 3 additions & 0 deletions crates/rolldown/src/bundler/stages/bundle_stage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ impl<'a> BundleStage<'a> {
}
});
for stmt_info in module.stmt_infos.iter() {
if !stmt_info.is_included {
continue;
}
for declared in &stmt_info.declared_symbols {
let symbol = self.link_output.symbols.get_mut(*declared);
debug_assert!(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/default/ambiguous_reexport_msg
## entry_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// a.js
let a = 1, x$1 = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import "http://example.com/code.js";
import "https://example.com/code.js";
import "//example.com/code.js";
import "data:application/javascript;base64,ZXhwb3J0IGRlZmF1bHQgMTIz";
import { __export } from "./_rolldown_runtime.mjs";
// entry.js
```
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/default/avoid_tdz
## entry_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// entry.js
class Foo {
static foo=new Foo();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ input_file: crates/rolldown/tests/esbuild/default/es6_from_common_js
## entry_js.mjs

```js
import { __commonJSMin, __export, __toESM } from "./_rolldown_runtime.mjs";
import { __commonJSMin, __toESM } from "./_rolldown_runtime.mjs";
// foo.js
var require_foo = __commonJSMin((exports, module) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/default/export_chain
## entry_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// bar.js
const c = 123;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ input_file: crates/rolldown/tests/esbuild/default/import_missing_common_js
## entry_js.mjs

```js
import { __commonJSMin, __export, __toESM } from "./_rolldown_runtime.mjs";
import { __commonJSMin, __toESM } from "./_rolldown_runtime.mjs";
// foo.js
var require_foo = __commonJSMin((exports, module) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ input_file: crates/rolldown/tests/esbuild/default/nested_es6_from_common_js
## entry_js.mjs

```js
import { __commonJSMin, __export, __toESM } from "./_rolldown_runtime.mjs";
import { __commonJSMin, __toESM } from "./_rolldown_runtime.mjs";
// foo.js
var require_foo = __commonJSMin((exports, module) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ input_file: crates/rolldown/tests/esbuild/default/quoted_property

```js
import * as ns from "ext";
import { __export } from "./_rolldown_runtime.mjs";
// entry.js
console.log(ns.mustBeUnquoted, ns['mustBeQuoted']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ input_file: crates/rolldown/tests/esbuild/default/re_export_common_js_as_es6
## entry_js.mjs

```js
import { __commonJSMin, __export, __toESM } from "./_rolldown_runtime.mjs";
import { __commonJSMin, __toESM } from "./_rolldown_runtime.mjs";
// foo.js
var require_foo = __commonJSMin((exports, module) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/default/re_export_default_internal
## entry_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// foo.js
var foo_default = 'foo';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/default/require_child_dir_es6
## entry_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// dir/index.js
var dir_index_default = 123;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/default/require_parent_dir_es6
## dir_entry_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// index.js
var require_parent_dir_es6_index_default = 123;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/default/reserve_props
## entry_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// entry.js
var entry_default = {
foo_:0,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/default/simple_es6
## entry_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// foo.js
function fn() {
return 123;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/default/strict_mode_nested_fn_decl_kee
## entry_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// entry.js
function outer() {
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/default/use_strict_directive_bundle_es
## entry_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// entry.js
'use strict';let a = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/import_star/export_self_es6
## entry_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// entry.js
const foo = 123;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/import_star/import_of_export_star
## entry_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// bar.js
statement();
statement();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/import_star/import_of_export_star_of_i
## entry_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// baz.js
const value = 123;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ input_file: crates/rolldown/tests/esbuild/import_star/import_star_common_js_capt
## entry_js.mjs

```js
import { __commonJSMin, __export, __toESM } from "./_rolldown_runtime.mjs";
import { __commonJSMin, __toESM } from "./_rolldown_runtime.mjs";
// foo.js
var require_foo = __commonJSMin((exports, module) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ input_file: crates/rolldown/tests/esbuild/import_star/import_star_common_js_no_c
## entry_js.mjs

```js
import { __commonJSMin, __export, __toESM } from "./_rolldown_runtime.mjs";
import { __commonJSMin, __toESM } from "./_rolldown_runtime.mjs";
// foo.js
var require_foo = __commonJSMin((exports, module) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ input_file: crates/rolldown/tests/esbuild/import_star/import_star_common_js_unus
## entry_js.mjs

```js
import { __commonJSMin, __export, __toESM } from "./_rolldown_runtime.mjs";
import { __commonJSMin, __toESM } from "./_rolldown_runtime.mjs";
// foo.js
var require_foo = __commonJSMin((exports, module) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ input_file: crates/rolldown/tests/esbuild/import_star/namespace_import_missing_c
## entry_js.mjs

```js
import { __commonJSMin, __export, __toESM } from "./_rolldown_runtime.mjs";
import { __commonJSMin, __toESM } from "./_rolldown_runtime.mjs";
// foo.js
var require_foo = __commonJSMin((exports, module) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ input_file: crates/rolldown/tests/esbuild/import_star/namespace_import_unused_mi
## entry_js.mjs

```js
import { __commonJSMin, __export, __toESM } from "./_rolldown_runtime.mjs";
import { __commonJSMin, __toESM } from "./_rolldown_runtime.mjs";
// foo.js
var require_foo = __commonJSMin((exports, module) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ input_file: crates/rolldown/tests/esbuild/import_star/re_export_star_external_es

```js
import "foo";
import { __export } from "./_rolldown_runtime.mjs";
// entry.js
```
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/import_star/re_export_star_name_collis
## entry_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// c.js
let x = 1, y = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/import_star/re_export_star_name_collis
## entry_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// c.js
let x = 1, y = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/import_star/re_export_star_name_shadow
## entry_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// b.js
let x$1 = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/import_star/re_export_star_name_shadow
## entry_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// c.js
let x$1 = 2;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ input_file: crates/rolldown/tests/esbuild/splitting/assign-to-local
## a.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
import { foo, setFoo } from "./shared_js.mjs";
// a.js
Expand All @@ -18,7 +17,6 @@ console.log(foo);
## b.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
import { foo } from "./shared_js.mjs";
// b.js
Expand All @@ -27,8 +25,6 @@ console.log(foo);
## shared_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// shared.js
let foo;
function setFoo(value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ input_file: crates/rolldown/tests/esbuild/splitting/cross_chunk_assignment_depen
## a.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
import { setValue } from "./shared_js.mjs";
// a.js
Expand All @@ -17,15 +16,11 @@ setValue(123);
## b.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// b.js
```
## shared_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// shared.js
var observer;
var value;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/splitting/duplicate_chunk_collision
## a.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// a.js
```
## ab_js.mjs
Expand All @@ -21,8 +19,6 @@ console.log(123);
## b.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// b.js
```
## c.mjs
Expand All @@ -33,8 +29,6 @@ import { __export } from "./_rolldown_runtime.mjs";
## cd_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// cd.js
console.log(123);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/splitting/dynamic-es6-into-es6
## foo_js.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// foo.js
let bar = 123;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ input_file: crates/rolldown/tests/esbuild/splitting/dynamic_and_not_dynamic_es6_
## foo_js-3.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// foo.js
let bar = 123;
Expand All @@ -25,7 +23,6 @@ export { bar };
## main.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
import { bar } from "./foo_js-3.mjs";
// main.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import('./b.mjs');
## b.mjs

```js
import { __export } from "./_rolldown_runtime.mjs";
// b.js
var b_default = 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export { a_ns, foo, init_a };
## b.mjs

```js
import { __export, __toCommonJS } from "./_rolldown_runtime.mjs";
import { __toCommonJS } from "./_rolldown_runtime.mjs";
import { a_ns, init_a } from "./a_js.mjs";
// b.js
Expand Down
Loading

0 comments on commit d9ccdb7

Please sign in to comment.