Microbundle: multiple entry modules

Created on 21 Jan 2020  路  5Comments  路  Source: developit/microbundle

Hi, there I an example of a package.json where I can see how to configure the multiple entry modules or any documentation?

question

Most helpful comment

Microbundle does support multiple entries that produce multiple outputs:

{
  "main": "dist/Assembler.js",
  "scripts": {
    "build": "microbundle src/*.ts"
  }
}

This will produce the following structure:

dist/
  a.js
  b.js
  c.js
src/
  a.ts
  b.ts
  c.ts
  lib/
    other.ts   <-- `src/*.ts` does not match this, so it will be bundled into a, b and c

All 5 comments

Also, when I try to call the bundled js file example (src/Assembler.ts becomes dist/Assembler.js) I get the error
ReferenceError: Can't find variable: module

Hi, not sure if I understand correctly but multiple entries are not yet supported by microbundle (AFAIK). See https://github.com/developit/microbundle/issues/50

For your second question it would help if you could provide steps to reproduce the problem. Seems as if it's tied to your application code

Too bad for the multiple entries.
For the second question.

I have a Typescript project the directory is:
assembler/

  • index.html
  • index.js
  • dist/

    • Assembler.js

    • ...some d.ts files

  • scr/

    • Assembler.ts

    • ...other ts files

When I compile using micro bundler it creates the dist folder with the final Assembler.js that contains the rest of the ts files as a single file.

But when I open index.html that in turn calls index.js I get the error:

Safari

SyntaxError: Importing binding name 'default' cannot be resolved by star export entries.

Chrome

Uncaught SyntaxError: The requested module './dist/Assembler.js' does not provide an export named 'default'

I want to know if I can open the files created by Microbundler from a local server without needing web pack.

Update: I manage to get the code running by importing Assembler.mjs instead of .js inside the index.js file

Microbundle does support multiple entries that produce multiple outputs:

{
  "main": "dist/Assembler.js",
  "scripts": {
    "build": "microbundle src/*.ts"
  }
}

This will produce the following structure:

dist/
  a.js
  b.js
  c.js
src/
  a.ts
  b.ts
  c.ts
  lib/
    other.ts   <-- `src/*.ts` does not match this, so it will be bundled into a, b and c
Was this page helpful?
0 / 5 - 0 ratings

Related issues

pBread picture pBread  路  15Comments

Conaclos picture Conaclos  路  11Comments

peter-mouland picture peter-mouland  路  12Comments

omgovich picture omgovich  路  16Comments

prateekbh picture prateekbh  路  17Comments