---
source: crates/biome_formatter_test/src/snapshot_builder.rs
info: js/module-blocks/module-blocks.js
---

# Input

```js
module { await 3 };

class B {
  #p() {
    module {
      class C { [this.#p]; }
    };
  }
}

const m = module {
  export const foo = "foo";
  export { foo };
};

module {
  export { foo }
};

const m = module       {};

const worker = new Worker(module {
  export const foo = "foo";
});

let m = module {
  module {
    export let foo = "foo";
  };
};

const m = module { export const foo = "foo" };

let moduleBlock = module { export let y = 1; };

foo(module { export let foo = "foo"; });

let m = module { /* foo */ };

```


# Prettier differences

```diff
--- Prettier
+++ Biome
@@ -1,50 +1,60 @@
-module {
+module;
+{
   await 3;
-};
+}
 
 class B {
   #p() {
-    module {
+    module;
+    {
       class C {
         [this.#p];
       }
-    };
+    }
   }
 }
 
-const m = module {
+const m = module;
+{
   export const foo = "foo";
   export { foo };
-};
+}
 
-module {
-  export { foo };
-};
+module;
+{
+  export { foo }
+}
 
-const m = module {};
+const m = module;
+{
+}
 
 const worker = new Worker(module {
   export const foo = "foo";
-});
+})
 
-let m = module {
-  module {
+let m = module;
+{
+  module;
+  {
     export let foo = "foo";
-  };
-};
+  }
+}
 
-const m = module {
-  export const foo = "foo";
-};
+const m = module;
+{
+  export const foo = "foo"
+}
 
-let moduleBlock = module {
+let moduleBlock = module;
+{
   export let y = 1;
-};
+}
 
-foo(module {
-  export let foo = "foo";
-});
+foo(module { export let foo = "foo";
+})
 
-let m = module {
+let m = module;
+{
   /* foo */
-};
+}
```

# Output

```js
module;
{
  await 3;
}

class B {
  #p() {
    module;
    {
      class C {
        [this.#p];
      }
    }
  }
}

const m = module;
{
  export const foo = "foo";
  export { foo };
}

module;
{
  export { foo }
}

const m = module;
{
}

const worker = new Worker(module {
  export const foo = "foo";
})

let m = module;
{
  module;
  {
    export let foo = "foo";
  }
}

const m = module;
{
  export const foo = "foo"
}

let moduleBlock = module;
{
  export let y = 1;
}

foo(module { export let foo = "foo";
})

let m = module;
{
  /* foo */
}
```

# Errors
```
module-blocks.js:1:8 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Expected a semicolon or an implicit semicolon after a statement, but found none
  
  > 1 │ module { await 3 };
      │        ^
    2 │ 
    3 │ class B {
  
  i An explicit or implicit semicolon is expected here...
  
  > 1 │ module { await 3 };
      │        ^
    2 │ 
    3 │ class B {
  
  i ...Which is required to end this statement
  
  > 1 │ module { await 3 };
      │ ^^^^^^^^
    2 │ 
    3 │ class B {
  
module-blocks.js:5:12 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Expected a semicolon or an implicit semicolon after a statement, but found none
  
    3 │ class B {
    4 │   #p() {
  > 5 │     module {
      │            ^
    6 │       class C { [this.#p]; }
    7 │     };
  
  i An explicit or implicit semicolon is expected here...
  
    3 │ class B {
    4 │   #p() {
  > 5 │     module {
      │            ^
    6 │       class C { [this.#p]; }
    7 │     };
  
  i ...Which is required to end this statement
  
    3 │ class B {
    4 │   #p() {
  > 5 │     module {
      │     ^^^^^^^^
    6 │       class C { [this.#p]; }
    7 │     };
  
module-blocks.js:11:18 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Expected a semicolon or an implicit semicolon after a statement, but found none
  
     9 │ }
    10 │ 
  > 11 │ const m = module {
       │                  ^
    12 │   export const foo = "foo";
    13 │   export { foo };
  
  i An explicit or implicit semicolon is expected here...
  
     9 │ }
    10 │ 
  > 11 │ const m = module {
       │                  ^
    12 │   export const foo = "foo";
    13 │   export { foo };
  
  i ...Which is required to end this statement
  
     9 │ }
    10 │ 
  > 11 │ const m = module {
       │ ^^^^^^^^^^^^^^^^^
    12 │   export const foo = "foo";
    13 │   export { foo };
  
module-blocks.js:12:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Illegal use of an export declaration not at the top level
  
    11 │ const m = module {
  > 12 │   export const foo = "foo";
       │   ^^^^^^^^^^^^^^^^^^^^^^^^^
    13 │   export { foo };
    14 │ };
  
  i move this declaration to the top level
  
module-blocks.js:13:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Illegal use of an export declaration not at the top level
  
    11 │ const m = module {
    12 │   export const foo = "foo";
  > 13 │   export { foo };
       │   ^^^^^^^^^^^^^^^
    14 │ };
    15 │ 
  
  i move this declaration to the top level
  
module-blocks.js:16:8 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Expected a semicolon or an implicit semicolon after a statement, but found none
  
    14 │ };
    15 │ 
  > 16 │ module {
       │        ^
    17 │   export { foo }
    18 │ };
  
  i An explicit or implicit semicolon is expected here...
  
    14 │ };
    15 │ 
  > 16 │ module {
       │        ^
    17 │   export { foo }
    18 │ };
  
  i ...Which is required to end this statement
  
    14 │ };
    15 │ 
  > 16 │ module {
       │ ^^^^^^^^
    17 │   export { foo }
    18 │ };
  
module-blocks.js:17:3 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Illegal use of an export declaration not at the top level
  
    16 │ module {
  > 17 │   export { foo }
       │   ^^^^^^^^^^^^^^
    18 │ };
    19 │ 
  
  i move this declaration to the top level
  
module-blocks.js:20:24 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Expected a semicolon or an implicit semicolon after a statement, but found none
  
    18 │ };
    19 │ 
  > 20 │ const m = module       {};
       │                        ^
    21 │ 
    22 │ const worker = new Worker(module {
  
  i An explicit or implicit semicolon is expected here...
  
    18 │ };
    19 │ 
  > 20 │ const m = module       {};
       │                        ^
    21 │ 
    22 │ const worker = new Worker(module {
  
  i ...Which is required to end this statement
  
    18 │ };
    19 │ 
  > 20 │ const m = module       {};
       │ ^^^^^^^^^^^^^^^^^^^^^^^
    21 │ 
    22 │ const worker = new Worker(module {
  
module-blocks.js:22:34 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × expected `,` but instead found `{`
  
    20 │ const m = module       {};
    21 │ 
  > 22 │ const worker = new Worker(module {
       │                                  ^
    23 │   export const foo = "foo";
    24 │ });
  
  i Remove {
  
module-blocks.js:23:10 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × expected `:` but instead found `const`
  
    22 │ const worker = new Worker(module {
  > 23 │   export const foo = "foo";
       │          ^^^^^
    24 │ });
    25 │ 
  
  i Remove const
  
module-blocks.js:23:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × expected `:` but instead found `foo`
  
    22 │ const worker = new Worker(module {
  > 23 │   export const foo = "foo";
       │                ^^^
    24 │ });
    25 │ 
  
  i Remove foo
  
module-blocks.js:23:27 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × expected `,` but instead found `;`
  
    22 │ const worker = new Worker(module {
  > 23 │   export const foo = "foo";
       │                           ^
    24 │ });
    25 │ 
  
  i Remove ;
  
module-blocks.js:24:1 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Expected a statement but instead found '})'.
  
    22 │ const worker = new Worker(module {
    23 │   export const foo = "foo";
  > 24 │ });
       │ ^^
    25 │ 
    26 │ let m = module {
  
  i Expected a statement here.
  
    22 │ const worker = new Worker(module {
    23 │   export const foo = "foo";
  > 24 │ });
       │ ^^
    25 │ 
    26 │ let m = module {
  
module-blocks.js:26:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Expected a semicolon or an implicit semicolon after a statement, but found none
  
    24 │ });
    25 │ 
  > 26 │ let m = module {
       │                ^
    27 │   module {
    28 │     export let foo = "foo";
  
  i An explicit or implicit semicolon is expected here...
  
    24 │ });
    25 │ 
  > 26 │ let m = module {
       │                ^
    27 │   module {
    28 │     export let foo = "foo";
  
  i ...Which is required to end this statement
  
    24 │ });
    25 │ 
  > 26 │ let m = module {
       │ ^^^^^^^^^^^^^^^
    27 │   module {
    28 │     export let foo = "foo";
  
module-blocks.js:27:10 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Expected a semicolon or an implicit semicolon after a statement, but found none
  
    26 │ let m = module {
  > 27 │   module {
       │          ^
    28 │     export let foo = "foo";
    29 │   };
  
  i An explicit or implicit semicolon is expected here...
  
    26 │ let m = module {
  > 27 │   module {
       │          ^
    28 │     export let foo = "foo";
    29 │   };
  
  i ...Which is required to end this statement
  
    26 │ let m = module {
  > 27 │   module {
       │   ^^^^^^^^
    28 │     export let foo = "foo";
    29 │   };
  
module-blocks.js:28:5 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Illegal use of an export declaration not at the top level
  
    26 │ let m = module {
    27 │   module {
  > 28 │     export let foo = "foo";
       │     ^^^^^^^^^^^^^^^^^^^^^^^
    29 │   };
    30 │ };
  
  i move this declaration to the top level
  
module-blocks.js:32:18 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Expected a semicolon or an implicit semicolon after a statement, but found none
  
    30 │ };
    31 │ 
  > 32 │ const m = module { export const foo = "foo" };
       │                  ^
    33 │ 
    34 │ let moduleBlock = module { export let y = 1; };
  
  i An explicit or implicit semicolon is expected here...
  
    30 │ };
    31 │ 
  > 32 │ const m = module { export const foo = "foo" };
       │                  ^
    33 │ 
    34 │ let moduleBlock = module { export let y = 1; };
  
  i ...Which is required to end this statement
  
    30 │ };
    31 │ 
  > 32 │ const m = module { export const foo = "foo" };
       │ ^^^^^^^^^^^^^^^^^
    33 │ 
    34 │ let moduleBlock = module { export let y = 1; };
  
module-blocks.js:32:20 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Illegal use of an export declaration not at the top level
  
    30 │ };
    31 │ 
  > 32 │ const m = module { export const foo = "foo" };
       │                    ^^^^^^^^^^^^^^^^^^^^^^^^
    33 │ 
    34 │ let moduleBlock = module { export let y = 1; };
  
  i move this declaration to the top level
  
module-blocks.js:34:26 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Expected a semicolon or an implicit semicolon after a statement, but found none
  
    32 │ const m = module { export const foo = "foo" };
    33 │ 
  > 34 │ let moduleBlock = module { export let y = 1; };
       │                          ^
    35 │ 
    36 │ foo(module { export let foo = "foo"; });
  
  i An explicit or implicit semicolon is expected here...
  
    32 │ const m = module { export const foo = "foo" };
    33 │ 
  > 34 │ let moduleBlock = module { export let y = 1; };
       │                          ^
    35 │ 
    36 │ foo(module { export let foo = "foo"; });
  
  i ...Which is required to end this statement
  
    32 │ const m = module { export const foo = "foo" };
    33 │ 
  > 34 │ let moduleBlock = module { export let y = 1; };
       │ ^^^^^^^^^^^^^^^^^^^^^^^^^
    35 │ 
    36 │ foo(module { export let foo = "foo"; });
  
module-blocks.js:34:28 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Illegal use of an export declaration not at the top level
  
    32 │ const m = module { export const foo = "foo" };
    33 │ 
  > 34 │ let moduleBlock = module { export let y = 1; };
       │                            ^^^^^^^^^^^^^^^^^
    35 │ 
    36 │ foo(module { export let foo = "foo"; });
  
  i move this declaration to the top level
  
module-blocks.js:36:12 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × expected `,` but instead found `{`
  
    34 │ let moduleBlock = module { export let y = 1; };
    35 │ 
  > 36 │ foo(module { export let foo = "foo"; });
       │            ^
    37 │ 
    38 │ let m = module { /* foo */ };
  
  i Remove {
  
module-blocks.js:36:21 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × expected `:` but instead found `let`
  
    34 │ let moduleBlock = module { export let y = 1; };
    35 │ 
  > 36 │ foo(module { export let foo = "foo"; });
       │                     ^^^
    37 │ 
    38 │ let m = module { /* foo */ };
  
  i Remove let
  
module-blocks.js:36:25 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × expected `,` but instead found `foo`
  
    34 │ let moduleBlock = module { export let y = 1; };
    35 │ 
  > 36 │ foo(module { export let foo = "foo"; });
       │                         ^^^
    37 │ 
    38 │ let m = module { /* foo */ };
  
  i Remove foo
  
module-blocks.js:36:29 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Did you mean to use a `:`? An `=` can only follow a property name when the containing object literal is part of a destructuring pattern.
  
    34 │ let moduleBlock = module { export let y = 1; };
    35 │ 
  > 36 │ foo(module { export let foo = "foo"; });
       │                             ^
    37 │ 
    38 │ let m = module { /* foo */ };
  
module-blocks.js:36:36 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × expected `,` but instead found `;`
  
    34 │ let moduleBlock = module { export let y = 1; };
    35 │ 
  > 36 │ foo(module { export let foo = "foo"; });
       │                                    ^
    37 │ 
    38 │ let m = module { /* foo */ };
  
  i Remove ;
  
module-blocks.js:36:38 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Expected a statement but instead found '})'.
  
    34 │ let moduleBlock = module { export let y = 1; };
    35 │ 
  > 36 │ foo(module { export let foo = "foo"; });
       │                                      ^^
    37 │ 
    38 │ let m = module { /* foo */ };
  
  i Expected a statement here.
  
    34 │ let moduleBlock = module { export let y = 1; };
    35 │ 
  > 36 │ foo(module { export let foo = "foo"; });
       │                                      ^^
    37 │ 
    38 │ let m = module { /* foo */ };
  
module-blocks.js:38:16 parse ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

  × Expected a semicolon or an implicit semicolon after a statement, but found none
  
    36 │ foo(module { export let foo = "foo"; });
    37 │ 
  > 38 │ let m = module { /* foo */ };
       │                ^
    39 │ 
  
  i An explicit or implicit semicolon is expected here...
  
    36 │ foo(module { export let foo = "foo"; });
    37 │ 
  > 38 │ let m = module { /* foo */ };
       │                ^
    39 │ 
  
  i ...Which is required to end this statement
  
    36 │ foo(module { export let foo = "foo"; });
    37 │ 
  > 38 │ let m = module { /* foo */ };
       │ ^^^^^^^^^^^^^^^
    39 │ 
  

```