Skip to content
This repository has been archived by the owner on Jun 25, 2020. It is now read-only.

Is it possible to use with modules of node_modules? #56

Open
emirdeliz opened this issue Sep 1, 2017 · 2 comments
Open

Is it possible to use with modules of node_modules? #56

emirdeliz opened this issue Sep 1, 2017 · 2 comments

Comments

@emirdeliz
Copy link

emirdeliz commented Sep 1, 2017

Is it possible to use with modules of node_modules?

When using this i receive TypeError: cb is not a function

My code is:
import Display from 'bundle-loader?lazy!../../node_modules/<module>/widgets/Display/Display.component.jsx';

@alexander-akait
Copy link
Member

@emirdeliz can you provide minimum reproducible test repo, thanks!

@emirdeliz
Copy link
Author

@evilebottnawi of course, see the code below:

var React = require('react');
var ReactDOM = require('react-dom');

/* Import from node_modules without bundle-loader */
var bundleTest = require('react-bundle-loader-test/index.js');

/* works fine! */
bundleTest();

/*  Import from node_modules with bundle-loader */
var bundleTest_lazy = require('bundle-loader?lazy!react-bundle-loader-test/index.js');

/* Uncaught TypeError: cb is not a function  */
bundleTest_lazy();

/*
  *** content of react-bundle-loader-test/index.js in node_modules ***

  module.exports = function() {
    console.log('Test react-bundle-loader-test ...');
  }
*/

ReactDOM.render(<h1>Hello React!</h1>, document.getElementById('root'));

See attached project
example.zip
react-bundle-loader-test.zip

I'm using two projects in my real case. One called widgets and another main project. The main project contains widgets as a dependency, so I need to load the widgets as asynchronous.

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

No branches or pull requests

2 participants