Skip to content

node-resolve doesn't import dependencies #828

@mlbonniec

Description

@mlbonniec

Expected Behavior

Hi, I'm trying to compile my TypeScript files into JS, but the problem is that nodeResolve doesn't seem to work properly. For example, when I use axios, in my build, axios is not defined, yet at the beginning of my file it says "require('axios')". Yet it is "undefined" in all my file. Do you have an idea of the problem?

Actual Behavior

The compiled files use dependencies that are "undefined". However, no errors during compilation.

Here's my actual rollup.config.js file.

import typescript from '@rollup/plugin-typescript';
import commonJS from '@rollup/plugin-commonjs';
import { nodeResolve } from '@rollup/plugin-node-resolve';
import { dependencies } from './package.json';

const deps = Object.keys(dependencies);
export default [
  {
    input: './src/MMM-NiceHash.ts',
    plugins: [
      nodeResolve(),
      typescript(),
      commonJS(),
    ],
    external: [...deps],
    output: {
      file: './MMM-NiceHash.js',
      format: 'umd',
      globals: {
        axios: 'axios',
        uuid: 'uuid',
      },
    },
  },
  {
    input: './src/node_helper.ts',
    plugins: [
      nodeResolve(),
      typescript(),
      commonJS(),
    ],
    external: ['node_helper', 'crypto', ...deps],
    output: {
      file: './node_helper.js',
      format: 'umd',
      globals: {
        axios: 'axios',
        uuid: 'uuid',
        crypto: 'crypto',
      },
    },
  },
];

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