Skip to content
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

Merged
merged 4 commits into from
Nov 12, 2017
Merged

Conversation

simen
Copy link
Member

@simen simen commented Nov 11, 2017

Quickly generate image urls from Sanity image records + a builder api for the Sanity image pipeline url options.

Copy link
Member

@rexxars rexxars left a 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",
Copy link
Member

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"
Copy link
Member

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?

Copy link
Member

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",
Copy link
Member

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?

Copy link
Member

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

Copy link
Member

@bjoerge bjoerge left a 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.

@@ -0,0 +1,10 @@
{
"presets": ["es2015", "react"],
Copy link
Member

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

"transform-object-rest-spread",
"syntax-class-properties",
"transform-class-properties",
"lodash"
Copy link
Member

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
Copy link
Member

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

"sanity",
"sanity/react"
],
"parser": "babel-eslint"
Copy link
Member

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
Copy link
Member

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

Copy link
Member

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? :)

@@ -0,0 +1 @@
module.exports = require('./lib')
Copy link
Member

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",
Copy link
Member

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",
Copy link
Member

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
[
Copy link
Member

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')
Copy link
Member

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).

@simen simen merged commit 24ad431 into next Nov 12, 2017
@simen simen deleted the feature/hotspot-url branch November 12, 2017 20:22
@bjoerge bjoerge mentioned this pull request Nov 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants