rollup/rollup-plugin-node-resolve

Can't find file because of extension omitted

MichaelSL opened this issue · 4 comments

Hi!
I'm trying to make a bundle with Angular 2 on Windows and get this error:

Could not load /node_modules/rxjs/symbol/observable (imported by \node_modules\@angular\core\src\util\lang.js): ENOENT: no such file or directory, open '\node_modules\rxjs\symbol\observable'

Angular imports like this:

import { $$observable as symbolObservable } from 'rxjs/symbol/observable';

Is there any option to force adding .js to the import?

If I recall, to solve this you need the following line:

https://github.com/OasisDigital/angular-aot-es2015-rollup/blob/master/rollup.config.js#L38

    commonjs({
      // make it possible to find these individual intra-package files
      include: [
        'node_modules/rxjs/**'
      ]
    }),

That doesn't help me. I can see in your config that you are not using the resolve plugin that causes the error.
I have tried the same config on Linux and it works. Can someone provide a workaround for Windows?
My rollup config file:

import alias from 'rollup-plugin-alias';
import typescript from 'rollup-plugin-typescript';
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';

export default {
 entry: 'public/vendor.ts',
 dest: 'public/dist/vendor.es2015.js',
 format: 'iife',
 moduleName: 'vendor',
 plugins: [
   alias({ rxjs: __dirname + '/node_modules/rxjs' }),
   resolve({ module: true,
             main: true,
             preferBuiltins: true,
             extensions: [ '.js' ] }),
   commonjs({
      include: [
        'node_modules/rxjs/**'
      ]
    })
 ]
}

This is odd, it normally works fine — can you provide a repro please?

I can't reproduce now after completely removing and reinstalling node_modules. Closing the issue.