Skip to content

Commit

Permalink
wip: define only module factories
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Dec 8, 2024
1 parent ddc5461 commit 976d20f
Show file tree
Hide file tree
Showing 13 changed files with 27 additions and 38 deletions.
4 changes: 2 additions & 2 deletions crates/rolldown/src/ecmascript/format/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub fn render_app<'code>(
}

// chunk content
source_joiner.append_source("\n__rolldown_runtime.modules({\n");
source_joiner.append_source("var __rolldown_modules = {\n");
module_sources.iter().for_each(|(_, module_id, module_render_output)| {
source_joiner.append_source(format!(
"{}: function(__rolldown_runtime) {{",
Expand All @@ -39,7 +39,7 @@ pub fn render_app<'code>(
}
source_joiner.append_source("},\n");
});
source_joiner.append_source("});\n");
source_joiner.append_source("};\n");

if let Some(outro) = outro {
source_joiner.append_source(outro);
Expand Down
4 changes: 2 additions & 2 deletions crates/rolldown/src/rebuild/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ impl RebuildManager {
if !changed_modules.is_empty() {
// create hmr chunk
let mut source_joiner = SourceJoiner::default();
source_joiner.append_source("\n__rolldown_runtime.modules({\n");
source_joiner.append_source("\nvar __rolldown_modules = {\n");
for (module_id, module) in &changed_modules {
source_joiner.append_source(format!(
"{}: function(__rolldown_runtime) {{",
Expand All @@ -81,7 +81,7 @@ impl RebuildManager {
}
source_joiner.append_source("},\n");
}
source_joiner.append_source("});\n");
source_joiner.append_source("};\n");
let (content, mut map) = source_joiner.join();
let file_dir = options.cwd.as_path().join(&options.dir);
if let Some(map) = map.as_mut() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ snapshot_kind: text
## main.js

```js
__rolldown_runtime.modules({
var __rolldown_modules = {
"main.js": function(__rolldown_runtime) {
//#region main.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ snapshot_kind: text
## main.js

```js
__rolldown_runtime.modules({
var __rolldown_modules = {
"foo.js": function(__rolldown_runtime) {
//#region foo.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ snapshot_kind: text
## main.js

```js
__rolldown_runtime.modules({
var __rolldown_modules = {
"main.js": function(__rolldown_runtime) {
//#region main.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ snapshot_kind: text
## main.js

```js
__rolldown_runtime.modules({
var __rolldown_modules = {
"foo.js": function(__rolldown_runtime) {
//#region foo.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ snapshot_kind: text
## main.js

```js
__rolldown_runtime.modules({
var __rolldown_modules = {
"main.js": function(__rolldown_runtime) {
//#region main.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ snapshot_kind: text
## main.js

```js
__rolldown_runtime.modules({
var __rolldown_modules = {
"main.js": function(__rolldown_runtime) {
//#region main.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ snapshot_kind: text
## main.js

```js
__rolldown_runtime.modules({
var __rolldown_modules = {
"rolldown:runtime": function(__rolldown_runtime) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ snapshot_kind: text
## cube.js

```js
__rolldown_runtime.modules({
var __rolldown_modules = {
"square.js": function(__rolldown_runtime) {
//#region square.js
Expand Down Expand Up @@ -39,8 +38,7 @@ function cube(x) {
## main.js

```js
__rolldown_runtime.modules({
var __rolldown_modules = {
"hyper-cube.js": function(__rolldown_runtime) {
//#region hyper-cube.js
Expand Down Expand Up @@ -69,8 +67,7 @@ console.log(hyper_cube_exports.default(5));
## other-entry.js

```js
__rolldown_runtime.modules({
var __rolldown_modules = {
"other-entry.js": function(__rolldown_runtime) {
//#region other-entry.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ snapshot_kind: text
## main.js

```js
__rolldown_runtime.modules({
var __rolldown_modules = {
"rolldown:runtime": function(__rolldown_runtime) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ console.log(dep);

```js
__rolldown_runtime.modules({
var __rolldown_modules = {
"dep.js": function(__rolldown_runtime) {
//#region dep.js
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4127,41 +4127,41 @@ snapshot_kind: text
# tests/rolldown/function/format/app/export-all
- main-!~{000}~.js => main-C8JyO0Pq.js
- main-!~{000}~.js => main-C2fhg46c.js
# tests/rolldown/function/format/app/export-default-class
- main-!~{000}~.js => main-B7y_NdJ7.js
- main-!~{000}~.js => main-XV6nvXr2.js
# tests/rolldown/function/format/app/export-default-expr
- main-!~{000}~.js => main-DxPlJBbf.js
- main-!~{000}~.js => main-Bi9MTw2b.js
# tests/rolldown/function/format/app/export-default-fn
- main-!~{000}~.js => main-CpWZgeg3.js
- main-!~{000}~.js => main-DyhDAcZw.js
# tests/rolldown/function/format/app/export-named
- main-!~{000}~.js => main-DtsEkgbw.js
- main-!~{000}~.js => main-DOoEzyUq.js
# tests/rolldown/function/format/app/export-named-from
- main-!~{000}~.js => main-DHIOi3Lr.js
- main-!~{000}~.js => main-BA7Qc7Uu.js
# tests/rolldown/function/format/app/import
- main-!~{000}~.js => main-DKZyN37s.js
- main-!~{000}~.js => main-BLlCw-xy.js
# tests/rolldown/function/format/app/multiple_entry_modules
- main-!~{000}~.js => main-AkAKQngF.js
- other-entry-!~{001}~.js => other-entry-Cnlk6n3p.js
- cube-!~{002}~.js => cube-Beuobi3z.js
- main-!~{000}~.js => main-DAXIiw9l.js
- other-entry-!~{001}~.js => other-entry-D3MxylU_.js
- cube-!~{002}~.js => cube-CmpNDwx8.js
# tests/rolldown/function/format/app/require
- main-!~{000}~.js => main-BFFsZQki.js
- main-!~{000}~.js => main-8xgU3A1-.js
# tests/rolldown/function/format/cjs/conflict_exports_key
Expand Down

0 comments on commit 976d20f

Please sign in to comment.