Tags: gardenhq/o
Tags
Workaround for CDN's serving the package.json:main at package root
unpkg at least services up the main file at the root of package name.
For example:
```
require("packagename")
```
...will give you the source of `packagenames`'s main file, which may be
located at `packagename/lib/index.js` (note the sub folder).
As `packagename/lib/index.js` is actually being served from the
`/packagename` path, that means any path references within
`packagename/lib/index.js` will be wrong, for example:
```
// /packagename/lib/index.js
// as index.js is being served from /packagename
// ./stuff.js means /stuff.js
// not /packagename/lib/stuff.js as it should be
require("./stuff.js")
```
Looking at unpkg.com, it will redirect a request for `packagename` to
`/packagename@1.0.0` anyway, actually serving the file up at
`/packagename@1.0.0`. Ideally, I would imagine, this redirect would
figure out the package.json:main property and redirect to that, so a
request for `packagename` would redirect to
`/packagename@1.0.0/lib/index.js`. `./stuff.js` in the above example
would then resolve to `/packagename@1.0.0/lib/stuff.js` as you would
expect.
The workaround checks to see if the includepath is http based, and if so
looks for urls that are just 'packagenames', if it finds one it requests
the package.json to get the main value itself, and at least for the
moment re-requests its value to use instead.
Deal with paths in a better way 1. Add things to paths like '.js' etc in the node specific place (the node-like transport) 2. Make sure actual pathnames are in the bundle, not just the 'id' 3. Bump versions of dependencies 4. Make sure json isn't treated as javascript in the transformers
Scope-hoisting, synchronous runner, removal of process in everything 1. Start looking at using rollup for scope-hoisting. Currently working but need to work in a way for fast live-reloading to happen, exposed data-entry-dev for now to enable configuring so I can at least bundle with scope-hoisting enabled. 2. Add a 'synchronous runner' (s.js) similar to b.js, to 'magically' set up `o` so people can just run a straight node style script with no `o` wrapper. 3. Stop adding `process` in everywhere, which should be added only if required. It was only being used here for testing with react anyhow. Unfortunately means a major bump..
PreviousNext