store icon indicating copy to clipboard operation
store copied to clipboard

'NgReduxModule' is not exported by node_modules/@angular-redux/store/lib/src/index.js error

Open slavpilus opened this issue 9 years ago • 12 comments

I'm getting

🚨   'NgReduxModule' is not exported by node_modules/@angular-redux/store/lib/src/index.js
https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module
app/app.module.js (21:18)
21: import { NgRedux, NgReduxModule } from "@angular-redux/store";

when compiling with aot compiler: "aot": "ngc -p tsconfig-aot.json && rollup -c rollup.config.js" while using 6.2.0-alpha.21 (it is working fine in "6.2.0-alpha.7")

let me know if you need any further details

slavpilus avatar Apr 26 '17 11:04 slavpilus

can you try with 6.2.0?

The alphas are unstable :)

SethDavenport avatar Apr 26 '17 12:04 SethDavenport

6.2.0 is failing aot compilation for the same reason... 6.2.0-alpha.7 is compiling just fine but I'm also using MockNgRedux.getSelectorStub which seem to be introduced after alpha.7

slavpilus avatar Apr 26 '17 17:04 slavpilus

OK seems you're using rollup - which TBH I haven't tested. I've tested Angular-CLI (which is based on webpack) and SystemJS.

Any chance you could share a repo so I can troubleshoot?

SethDavenport avatar Apr 26 '17 20:04 SethDavenport

Or at least your tsconfig-aot.json and rollup.config.js?

SethDavenport avatar Apr 27 '17 00:04 SethDavenport

Here you are: tsconfig-aot.json:-

{
  "compilerOptions": {
    "target": "es5",
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es2015", "dom" ],
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true
  },
  "files": [
    "app/app.module.ts",
    "app/main-aot.ts"
  ],
  "angularCompilerOptions": {
    "genDir": "aot",
    "skipMetadataEmit": true
  }
}

rollup.config.js:-

import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs from 'rollup-plugin-commonjs'
import uglify from 'rollup-plugin-uglify'
import angular from 'rollup-plugin-angular';
import replace from 'rollup-plugin-replace'

export default {
    entry: 'app/main-aot.js',
    dest: 'app_dist/build.js',
    sourceMap: true,
    format: 'iife',
    onwarn: function (message) {
        if (/The 'this' keyword is equivalent to 'undefined' at the top level of an ES module, and has been rewritten./.test(message)) {
            return;
        }
    },
    plugins: [
        angular(),
        replace({
            'process.env.NODE_ENV': JSON.stringify( 'production' )
        }),
        nodeResolve({jsnext: true, module: true, browser: true}),
        commonjs(),
        uglify()
    ]
}

slavpilus avatar Apr 27 '17 06:04 slavpilus

I will set aside some time to dig into this tomorrow. Sorry for the delay.

SethDavenport avatar Apr 28 '17 21:04 SethDavenport

Yeah OK. Current theory is that it's due to a change in the way we export stuff. We went from this:

import { NgRedux } from './components/ng-redux';
import { DevToolsExtension } from './components/dev-tools';
import { select } from './decorators/select';
import { NgReduxModule } from './ng-redux.module';
 
export {
  NgRedux,
  NgReduxModule,
  DevToolsExtension,
  select,
}

to this:


export * from './components/ng-redux';
export * from './components/dev-tools';
export * from './decorators/select';
export * from './ng-redux.module';

Nicer to code. But it seems according to this that rollup can't handle it without additional config.

SethDavenport avatar May 01 '17 02:05 SethDavenport

I'll try flipping back to the previous style since it was just for convenience.

SethDavenport avatar May 01 '17 02:05 SethDavenport

@slavP can you give 6.2.1-alpha.0 a try and let me know?

SethDavenport avatar May 01 '17 02:05 SethDavenport

@SethDavenport the error has gone. I'm now able to compile successfully. Many thanks!

slavpilus avatar May 01 '17 09:05 slavpilus

Great - I will release an official 6.2.1 later today.

SethDavenport avatar May 01 '17 12:05 SethDavenport

6.2.1 released with a fix. Thanks.

SethDavenport avatar May 01 '17 13:05 SethDavenport