js-data-http
js-data-http copied to clipboard
Apply new mjs file extension and remove imports from dependencies
I'm using Node 8.5's new es module import to run a SPA application in SSR mode in Node. In this case it's very useful to have the sourcecode for Node running without the need to transpile it. The implementation for Node dictates that the file extension for modules is '.mjs'. By renaming index.js
to index.mjs
, Node can easily import and use the file. Transpilers like rollup can handle different extensions without any problems, so it shouldn't be a problem for legacy builds.
Also, I'm not sure if that's due to my rollup settings, but when I do an import like:
import {HttpAdapter as DSHttpAdapter} from 'js-data-http'
Rollup will include js-data twice(once from js-data-http and once from js-data-adapter). Wouldn't it be much easier to keep the bundle size small, by assuming a global like:
const {utils} = JSData
Instead of import { utils } from 'js-data'
Using an external option for js-data in rollup seems a bit cumbersome when js-data is included in the same vendor.js file. I add a pull request just as demo(what works for me). Please let me know if I can help out. The same thing applies for js-data-adapter
.
@jvanveen How is that fork working out for you? Do you have a public repo we can see it in action?