OverZealous / cdnizer

Node module for replacing local links with CDN links, includes fallbacks and customization
MIT License
52 stars 24 forks source link

cdnizer Bundling Scripts incorrectly? #27

Closed computersarecool closed 7 years ago

computersarecool commented 7 years ago

Hi,

In my .bower.json I have the following:

 "dependencies": {
  "angular": "1.5",
  "angular-resource": "1.5",
  "angular-sanitize": "1.5",
  "angular-route": "1.5"
}

In my index.html I have

  <script src="../bower_components/angular/angular.js"></script>
  <script src="../bower_components/angular-resource/angular-resource.js"></script>
  <script src="../bower_components/angular-sanitize/angular-sanitize.js"></script>
  <script src="../bower_components/angular-route/angular-route.js"></script>

But after running cdnizer, I am left with the following:

<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular.min.js"></script><script>if(!(window.angular)) cdnizerLoad("../bower_components/angular/angular.js");</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular.min.js"></script><script>if(!(window.angular)) cdnizerLoad("../bower_components/angular-resource/angular-resource.js");</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular.min.js"></script><script>if(!(window.angular)) cdnizerLoad("../bower_components/angular-sanitize/angular-sanitize.js");</script>
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.0/angular-route.min.js"></script><script>if(!(window.angular)) cdnizerLoad("../bower_components/angular-route/angular-route.js");</script>

In looking at the documentation it does not look like the resource, and sanitize packages are bundled, but here they are replaced with, and only checked with the larger angular.min script.

Furthermore, if they were bundled, having those three fallbacks seem redundant.

Is there a way that I can confirm if these packages should be bundled, and if they are not include the three script tags. Or, is this ideal for some reason?

OverZealous commented 7 years ago

It's a known bug.

Just add allowRev: false to your cdnizer config.

The allowRev is designed to work with hash-based revisioning, and it aggressively matches -.{8} at the end of the file name, which causes problems with anything that has that format.

I know it's been out there for a long while, I really should change the default options.

computersarecool commented 7 years ago

That does it thanks!