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
Added config file support #32
Conversation
Thanks! Few ways to improve PR:
|
As I understand, with cosmiconfig we can't handle both names at package.json 'size-limit' and 'sizeLimit'. |
I am OK with removing legacy |
Should I check existing of |
If we have |
|
Tests are failed cause there is spelling checking, but I didn't change thet part of |
Ouh. It is Yaspeller problem. I will fix it. |
Appveyor test failed on I will fix docs and error messages tomorrow |
About error messages, what do I need to fix? Can I add a link to the Config section at GitHub? |
Check out origin error messages. You will see that error messages were clear and tell exactly what and where should be changed.
Why
Add where?
What config and what it is exacty a error? |
Because it was so before |
Before it was about |
Ok, I will fix it. Do you know what may be wrong with AppVeyor CI, how can I fix it? |
Note, that |
I have fixed error messages, now the parsing error contains the path to the config and explanation of the error. |
README.md
Outdated
@@ -125,6 +125,35 @@ Add the `size` script to your test suite: | |||
If you don't have a continuous integration service running, don’t forget | |||
to add one — start with [Travis CI](https://github.com/dwyl/learn-travis). | |||
|
|||
## Config | |||
Add `size-limit` section to `package.json` and `size` script: |
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.
No newline after the title.
It is better to explicit say about 2 types of config.
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 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.
Yeap, looks good.
cli.js
Outdated
})) | ||
return limits | ||
}).then(limits => { | ||
return readPkg().then(packageJson => { |
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.
Why do we need readPkg
here?
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.
Because below we have
return {
webpack: limit.webpack !== false,
bundle: packageJson.pkg.name,
config: limit.config,
ignore: packageJson.pkg.peerDependencies,
limit: limit.limit,
full: files.map(i => path.join(cwd, i)),
files
}
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.
Ouh :(.
cli.js
Outdated
}).then(limits => { | ||
return readPkg().then(packageJson => { | ||
return Promise.all(limits.map(limit => { | ||
const cwd = path.dirname(packageJson.path) |
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.
For .size-limit
config you need to use its directory.
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.
Will fix it
test/cli.test.js
Outdated
return run([], { cwd: fixture('wrong-file-config') }).then(result => { | ||
expect(result.out).toContain( | ||
' ERROR Can not parse Size Limit config: \n' + | ||
'missed comma between flow collection entries' |
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.
All other error messages have indent on next lines.
ERROR Can not parse Size Limit config:
missed comma between flow collection entries
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.
Will fix it
Awesome. Thanks. I will accept and release it today evening. |
Thanks for your tips! |
Released in 0.13 |
Do I need to write more tests?