Code Monkey home page Code Monkey logo

Comments (5)

WebReflection avatar WebReflection commented on June 15, 2024 1

Extension type .mjs is very important to emphasize a JS file is to be loaded as a module.

On the Web, extensions are meaningless and PyScript supports only ESM as so does the web. Any import .js works without issues and some outdated server might never understand .mjs extension, so that if the mime-type is not text/javascript or application/javascript that file cannot be imported by browsers, no matter the extension name.

In NodeJS there are many ways to enforce modules as ESM, adding "type": "module" would already handle all .js files as ESM. The CJS has no meaning on the Web and if you use your own version of require that will work as those files will be evaluated as plain text, which is desired, while as modules these should fail, as the two module systems are not interchangeable.

All that being said, I believe the service should support .mjs seamlessly as that's currently a standard mime-type for modern server so it should be understood as such. However, this project is about the PyScript library itself, the Web / service exists as different project so I am pinging @FabioRosado here as he would know best what needs to be done and where (which is not in this repository).

Thanks for your patience and for filing the issue, I hope the .mjs part at least can be resolved soon.

from pyscript.

FabioRosado avatar FabioRosado commented on June 15, 2024 1

Hello and thank you @WebReflection for pinging me, this should be a one line fix, will implement today and then we will have to deploy 😄

from pyscript.

GoToLoop avatar GoToLoop commented on June 15, 2024

Add both ".mjs" & ".cjs" as well.

Maybe also TypeScript extensions such as ".jsx", ".tsx", ".ts", ".mts", ".cts".

from pyscript.

WebReflection avatar WebReflection commented on June 15, 2024

Add both ".mjs" & ".cjs" as well.

Maybe also TypeScript extensions such as ".jsx", ".tsx", ".ts", ".mts", ".cts".

one thing is to fix standards, one thing is to enable all possible variants that are not standard. I don't think you ever need those extensions to behave differently from plain/text but until those extensions are not part of standards, it's counter-productive to enable these in any way as we're just moving the issue we have here to the next live service where none of those extensions would return a meaningful mime-type neither.

.mjs has a standard mime-type defined by all standard bodies, everything else is not there yet and nobody should push for it, imho, if not behind standard processes.

from pyscript.

WebReflection avatar WebReflection commented on June 15, 2024

Closing as there's nothing to do for us in this specific repository.

from pyscript.

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.