Giter VIP home page Giter VIP logo

Comments (3)

frigus02 avatar frigus02 commented on May 26, 2024

Dynamic imports are only supported if the output chunk type is ES_MODULES. This works:

$ echo 'const x = async () => { const buffer = await import(/** @type {string} */("buffer")); alert("1", buffer);}; x();' | google-closure-compiler -W QUIET --module_resolution WEBPACK -O ADVANCED --chunk_output_type ES_MODULES
The compiler is waiting for input via stdin.
(async()=>{const a=await import("buffer");alert("1",a)})();export{};

The crash is not great, though. Would be nice if there was a good error message that mentioned the chunk type requirement.

from closure-compiler.

corrideat avatar corrideat commented on May 26, 2024

Thanks, I'll see if that works in my application.

Dynamic imports are only supported if the output chunk type is ES_MODULES.

Hm, that may be a design decision you've made and I'm fine leaving it at that. However, dynamic imports are, in principle, allowed everywhere (providing support for import, of course). E.g., <script>import('foo').finally(()=>alert("Yay!"))</script> is perfectly valid, no need for <script type="module"> there.

from closure-compiler.

hanguokai avatar hanguokai commented on May 26, 2024

It works in v20230502 and before, but it fails from v20230802. Hope this issue can be resolved soon.

from closure-compiler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.