Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A module cannot import itself #2

Closed
danielkcz opened this issue Jun 1, 2016 · 9 comments
Closed

A module cannot import itself #2

danielkcz opened this issue Jun 1, 2016 · 9 comments

Comments

@danielkcz
Copy link

First I got a same error as #1 so I also installed master version of commonjs and now I am getting this strange error.

A module cannot import itself (D:\workspace\stampit\node_modules\rollup-plugin-node-globals\src\global.js)
Error: A module cannot import itself (D:\workspace\stampit\node_modules\rollup-plugin-node-globals\src\global.js)
    at D:\workspace\stampit\node_modules\rollup\src\Bundle.js:223:14
    at tryCatch (D:\workspace\stampit\node_modules\rollup\node_modules\es6-promise\lib\es6-promise\-internal.js:185:12)
    at invokeCallback (D:\workspace\stampit\node_modules\rollup\node_modules\es6-promise\lib\es6-promise\-internal.js:197:13)
    at publish (D:\workspace\stampit\node_modules\rollup\node_modules\es6-promise\lib\es6-promise\-internal.js:168:7)
    at flush (D:\workspace\stampit\node_modules\rollup\node_modules\es6-promise\lib\es6-promise\asap.js:87:5)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

Essentially I am trying to create bundle of unit tests so they can be run in a browser. This is whole config I am using...

import babel from 'rollup-plugin-babel';
import nodeResolve from 'rollup-plugin-node-resolve';
import commonJs from 'rollup-plugin-commonjs';
import json from 'rollup-plugin-json';
import nodeGlobals from 'rollup-plugin-node-globals';
import nodeBuiltins from 'rollup-plugin-node-builtins';

export default {
  entry: 'test/basics.js',
  format: 'iife',
  dest: 'testBundle.js',
  plugins: [
    nodeBuiltins(),
    nodeResolve({ jsnext: true, main: true, browser: true }),
    commonJs({ ignoreGlobal: true }),
    nodeGlobals(),
    json(),
    babel({
      babelrc: false,
      exclude: 'node_modules/**',
      presets: ['es2015-rollup', 'stage-1'],
      plugins: ['transform-runtime'],
      runtimeHelpers: true
    }),
  ]
};

It's on Node v6.2.0.

@calvinmetcalf
Copy link
Owner

yeah I don't think it likes the run time

@danielkcz
Copy link
Author

Well I don't think that's the case. I tried to disable while babel plugin and error stays the same. It makes sense because of exclude: 'node_modules/**', so it shouldn't run this rollup plugin through babel at all. What else could it be?

Disabling nodeGlobals plugin I am getting this output:

Treating 'fs' as external dependency
Treating 'module' as external dependency
Treating 'fs' as external dependency
Treating 'fs' as external dependency
Error parsing D:\workspace\stampit\node_modules\rollup-plugin-node-builtins\src\es6\util.js: 'import' and 'export' may only appear at the top level (24:0) in D:\workspace\stampit\node_modules\rollup-plugin-node-builtins\src\es6\util.js

For the reference actual test file contains just one simple test and import of ava test runner. I know there are some talks it doesn't work well, but I was hoping this might solve it since ava just needs bunch of node related stuff.

@calvinmetcalf
Copy link
Owner

ok see this comment of the required steps to get them all working together

@barneycarroll
Copy link

I had difficulties with a lot of tooling in node 6 so rolled back to LTS. I'm getting this on node 4.4.5.

@calvinmetcalf
Copy link
Owner

@barneycarroll can you be a bit more specific ?

@barneycarroll
Copy link

Sorry @calvinmetcalf, I appreciate that's not a very helpful bug report :)

I only encountered this bug in trying to help out a friend with their rollup import of browserify-assuming UMD packages, and encountered this on Windows 7. This was not the bug they were seeing :) I will get back to you tomorrow on this.

@calvinmetcalf
Copy link
Owner

also woops I was getting this one confused with a different issue, I'm going to look into this, looks like the 'global' file can accedentally try to import itself

@calvinmetcalf
Copy link
Owner

ok I should be able to add the global and buffer files to the exclude list for this so it doesn't run on them

@calvinmetcalf
Copy link
Owner

done in 1.0.6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants