-
Notifications
You must be signed in to change notification settings - Fork 405
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[image-url] Introducing the image-url package #352
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few meta changes needed, functionality wise this looks great!
@@ -0,0 +1,38 @@ | |||
{ | |||
"name": "@sanity/image-url", | |||
"version": "0.119.0", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be 0.120.0
"lint": "eslint .", | ||
"pre-commit-check": | ||
"npm test && (eslint . || (echo 'Warning: project has lint errors. Please fix and re-commit with `git commit --amend`' && echo))", | ||
"test": "mocha --recursive --require babel-register test" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
babel-register should probably be added to dev dependencies?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably want to add eslint with Sanity config and a lint task
"babelify": "^7.3.0", | ||
"browserify": "^14.3.0", | ||
"mocha": "^3.2.0", | ||
"remon": "^1.0.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't think remon is used in this project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither is browserify/babelify if the bloat task is removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Found a few meta issues too, otherwise looks good. What compatibility are we targeting here? I see there's a few Object.assign usages here, which means it will not work in IE without a polyfill.
packages/@sanity/image-url/.babelrc
Outdated
@@ -0,0 +1,10 @@ | |||
{ | |||
"presets": ["es2015", "react"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The react preset should be removed from here
packages/@sanity/image-url/.babelrc
Outdated
"transform-object-rest-spread", | ||
"syntax-class-properties", | ||
"transform-class-properties", | ||
"lodash" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can see, neither of these plugins are actually needed and should also be removed.
@@ -0,0 +1 @@ | |||
/lib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'd probably want to add node_modules
here too
packages/@sanity/image-url/.eslintrc
Outdated
"sanity", | ||
"sanity/react" | ||
], | ||
"parser": "babel-eslint" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think babel-eslint is needed
@@ -0,0 +1,4 @@ | |||
example |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's no example folder
npm install --save @sanity/image-url | ||
|
||
## Usage | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe write a bit more on this part? :)
packages/@sanity/image-url/index.js
Outdated
@@ -0,0 +1 @@ | |||
module.exports = require('./lib') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO ./lib/index.js
is an unnecessary indirection, and it would be better to skip it, and instead require ./lib/builder.js
directly here. Also i think there's an issue with mix of export / commonjs requires here that can be avoided with:
module.exports = require('./lib/builder').default
"scripts": { | ||
"clean": "rimraf lib", | ||
"bloat": | ||
"browserify -t babelify --full-paths ./src/index.js | discify --open", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "bloat" script here is not that useful and can be removed (I also don't think it will work since disc
is not added as a dependency)
"babelify": "^7.3.0", | ||
"browserify": "^14.3.0", | ||
"mocha": "^3.2.0", | ||
"remon": "^1.0.2", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither is browserify/babelify if the bloat task is removed
} | ||
|
||
// Map from spec name to url param name | ||
[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These could be extracted as a global constant
@@ -0,0 +1 @@ | |||
export default require('./builder') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of mixing ES import / commonjs require you can do export {default} from './builder'
. That said, I don't think this file is needed (see my other comment).
Quickly generate image urls from Sanity image records + a builder api for the Sanity image pipeline url options.