Skip to content

ES module support for Node JS #277

@ghost

Description

Standards compliant way to load module is ES Modules not CommonJS in Node.

E.g. ESM Declaration

export default async function MyFunc(context) {
  return {
      status: 200,
      body: "hello, world!\n"
  };
}

ESM module use

import {MyFunc} from "my-module.mjs";

vs

CommonJS declaraion

module.exports = async function(context) {
    return {
        status: 200,
        body: "hello, world!\n"
    };
}

CommonJS use

const myModule = require("my-modules.cjs);

Is there a way to make NODE's ESM's imports / module declarations work in Fission?

Tried it locally and it did not work. Could not find any mentions/examples in your repos either

ESM is the recommended way to build Node JS code these days

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions