visionmedia / page.js

Micro client-side router inspired by the Express router
http://visionmedia.github.com/page.js
7.67k stars 687 forks source link

CommonJS "require()" in page.js file loaded from browser #521

Closed wollanup closed 5 years ago

wollanup commented 5 years ago

Just to make sure... Is that an expected behavior that page.js uses

var pathtoRegexp = require('path-to-regexp');

in the latest commit ?

The file page.js is supposed to be used in a client side environment (browser), not in Node environment ?

JpabloR commented 5 years ago

i have the same problem.

bbarr commented 5 years ago

TLDR - Use the cdnjs or unpkg links on the README, not the rawgit link on the public marketing site. Keep the version at 1.11.1

This is not ES6, this is commonjs and certainly has no place in the built file of a client-side library. The tests don't catch it either, so, must be configured incorrectly or else it is going through another build stage for them.. which would make even less sense. Hopefully someone with time (unfortunately not I) can dig into it more today, because this is probably affecting a lot of people.

wollanup commented 5 years ago

@bbarr Yes I switched to https://unpkg.com/page@1.11.1/page.js instead of https://cdn.rawgit.com/visionmedia/page.js/master/page.js (and told my devs again to never use untagged/master versions! :angry: )

You're right about CommonJS, I have confused require() with import, updated title ;)

ghost commented 5 years ago

...just before the weekend :/ Had to switch from the master-version as well. grrrrmpfff

matthewp commented 5 years ago

Not sure why this happened. Looking into it.

matthewp commented 5 years ago

Ok, this is fixed in 1.11.2. Sorry about that.

ghost commented 5 years ago

Thanks.