简体   繁体   中英

Loading bower modules via require() in brunch-compiled site

I'm trying to use this module in my site that is built with Brunch:

https://github.com/rodneyrehm/viewport-units-buggyfill

Brunch correctly picks it up via the Bower config file and compiles it into the vendor.js file. So far so good. But the suggested require() line fails with:

Uncaught Error: Cannot find module "viewport-units-buggyfill" from "/"

Reading the source, I don't see how the module defines its name. I guess it's supposed to use the filename like node.js modules, and the Brunch compiler loses that when it concatenates files?

I'm not very familiar with these module systems, obviously. But it sounds appealing if I can get it to work, rather than pollute the global namespace. Can anyone help?

Answering my own question...

It turns out, what I was looking for had been answered already. I'd even read it before, but hadn't understood it until now!

Loading vendor javascript as modules

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM