Skip to content

Add support for CommonJS #23

@astolcenburg

Description

@astolcenburg

Hi,

my organization would like to use ThunderJS library in node.js application running on STB. We would like to request for adding direct CommonJS support so that this library can be used without the need for additional translation.

I think the easiest way to achieve this is to add an extra target to the rollup.config.js file:

  {
    input: './src/thunderJS.js',
    output: {
      file: './dist/thunderJS.cjs',
      format: 'cjs',
      name: 'ThunderJS',
    },
    external: [ 'ws' ],
    plugins: [
      commonjs(),
      cleanup(),
      license({
        banner: {
          content: LicenseBanner,
        },
      }),
    ],
  },

This will generate a new ./dist/thunderJS.cjs file. After committing the file to the repository, we can modify the "main" property of the package.json file to point to that file:

-  "main": "src/thunderJS.js",
+  "main": "dist/thunderJS.cjs",

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions