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

webpack warning when importing dcl / dynamic use of require calls #24

Closed
casdevs opened this issue Jul 10, 2017 · 5 comments
Closed

webpack warning when importing dcl / dynamic use of require calls #24

casdevs opened this issue Jul 10, 2017 · 5 comments
Assignees

Comments

@casdevs
Copy link

casdevs commented Jul 10, 2017

First of all, thanks @uhop for your new major release - it's great that you're continuosly improving the library!

When using it on a node.js project with webpack bundling, webpack gives the following warnings:

WARNING in ./node_modules/dcl/dcl.js
1:94-101 Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

WARNING in ./node_modules/dcl/dcl.js
1:162-172 Critical dependency: the request of a dependency is an expression

seems it cannot do a static analysis on required modules because of the

/* UMD.define */ (typeof define=="function"&&define||function(d,f,m){m={module:module,require:require};module.exports=f.apply(null,d.map(function(n){return m[n]||require(n)}))})

line where a variable is passed to the require function.

For more information, also please have a look at the discussion in webpack/webpack#196.

Could this be easily replaced with more static parameters to the require function?

Thanks & with best regards,
Stefan

@casdevs casdevs changed the title webpack warning when using dcl webpack warning when importing dcl / dynamic use of require calls Jul 10, 2017
@uhop uhop self-assigned this Jul 10, 2017
@uhop
Copy link
Owner

uhop commented Jul 10, 2017

I am already building a version with globals for browsers (some people prefer this style as being easier to integrate). It looks like I should start build a special static version for tools like webpack.

@clubajax
Copy link

@uhop: Depending on if you are using web components or not, webpack could use the source (if using WC, it needs to be babel-ized). It could be a simple matter of changing the "main" in the npm package.

@uhop
Copy link
Owner

uhop commented Jul 16, 2017

I looked into that more. For browser + Babel, it is easier to use dcl with globals (see dist directory). For node + Babel, it works out of box as is (Babel can import CommonJS modules without problems without compiling them). Just don't compile dcl.

@uhop
Copy link
Owner

uhop commented Jul 16, 2017

I added ES6 distro in dd2fceb AKA version 2.0.3 published on npm. How to use it documented in README. Try it, and reopen the ticket, if you have any problems. I am interested to play nice with Babel in all possible configurations, because ES6 will be a native version of the upcoming dcl6.

@uhop
Copy link
Owner

uhop commented Jul 17, 2017

I tried it in the real React project. Use 2.0.5, which has some downgraded prologue for ES6 modules. The original 2.0.3 has used a lambda, which was some reason was rejected by Babel.

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

No branches or pull requests

3 participants