plugins icon indicating copy to clipboard operation
plugins copied to clipboard

[!] (plugin alias) TypeError: Cannot read property 'input' of undefined

Open shaoahs opened this issue 6 years ago • 6 comments

  • Rollup Plugin Name: @rollup/plugin-node-resolve
  • Rollup Plugin Version: 8.0.0
  • Rollup Version: 2.10.9
  • Operating System (or Browser): linux mageia 7.1
  • Node Version: v12.16.1

How Do We Reproduce?

if also use @rollup/plugin-alias https://repl.it/repls/FrailSilverPoints#rollup.config.js

if modify https://github.com/rollup/plugins/blob/master/packages/node-resolve/src/index.js

line 125

      const input = normalizeInput(rollupOptions.input);

to

        if(!rollupOptions || !rollupOptions.input) {
          rollupOptions = {
            input: importee
          };
        }

        const input = normalizeInput(rollupOptions.input);

then it is normal ! is it okay for other plugins ?

Expected Behavior

> npm run build

src/demo/main.js → public/bundle.js...
created public/bundle.js in 2.2s

Actual Behavior

> npm run build

[!] (plugin alias) TypeError: Cannot read property 'input' of undefined
TypeError: Cannot read property 'input' of undefined
    at node_modules/@rollup/plugin-node-resolve/dist/index.js:509:52
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (node_modules/@rollup/plugin-node-resolve/dist/index.js:20:24)
    at _next (node_modules/@rollup/plugin-node-resolve/dist/index.js:42:9)
    at node_modules/@rollup/plugin-node-resolve/dist/index.js:49:7
    at new Promise (<anonymous>)
    at node_modules/@rollup/plugin-node-resolve/dist/index.js:38:12
    at resolveId (node_modules/@rollup/plugin-node-resolve/dist/index.js:642:9)
    at Object.resolveId (/node_modules/@rollup/plugin-alias/dist/index.js:79:24)
    at node_modules/rollup/dist/shared/rollup.js:18285:25

shaoahs avatar May 26 '20 01:05 shaoahs

Can you add a minimal example of this error happening without any other plugins using one of the REPLs?

shellscape avatar May 26 '20 01:05 shellscape

if only use @rollup/plugin-node-resolve , it is okay !

need use two plugins ! (minimal)

import alias from '@rollup/plugin-alias';
import resolve from '@rollup/plugin-node-resolve';

shaoahs avatar May 26 '20 03:05 shaoahs

is it this ? https://repl.it/repls/FrailSilverPoints#rollup.config.js

shaoahs avatar May 26 '20 03:05 shaoahs

@colesico Please do not post "me too" type replies. Instead, use the reaction buttons. If you need an issue fixed immediately, please consider contributing a fix.

shellscape avatar May 28 '20 11:05 shellscape

current status (use the same config)

I am not sure ! need modify plugin "@rollup/plugin-alias" or "@plugin-node-resolve" in last version

option 1

it is work !

  "@rollup/plugin-alias": "^3.1.0",
  "@rollup/plugin-node-resolve": "~7.0.0"

option 2

error !

  "@rollup/plugin-alias": "^3.1.0",
  "@rollup/plugin-node-resolve": "~8.0.0"

config

// rollup.config.js
import alias from '@rollup/plugin-alias';
import resolve from '@rollup/plugin-node-resolve';

const customResolver = resolve({
  extensions: ['.ts', '.mjs', '.js', '.yml', '.json', '.css']
});

let aliasConfig = {
  customResolver,
  entries: {
    'update': path.resolve('src/demo/update.js'),
    'src': path.resolve('src/demo/')
  }
};

export default {
  // ...
  plugins: [
    alias(aliasConfig),
    resolve()
  ]
};

shaoahs avatar May 29 '20 00:05 shaoahs

Thanks for the reproduction. This is a duplicate of #203

shellscape avatar May 29 '20 15:05 shellscape