ojkelly/yarn.build

[BUG] Missing source directory fails silently

Closed this issue · 3 comments

Describe the bug
When the source directory cannot be found, yarn.build will fail silently.

To Reproduce
Steps to reproduce the behavior:

  1. Rename any of the example projects src to source
  2. Run yarn build
  3. The build completes apparently without errors.

Expected behavior
There should be an error message that the expected src directory does not exist. This is visible when running with --verbose, but I don't think that's enough.

Ideally, it should also be checked if yarn.build has been configured in the manifest to print some guidance for the user, for example:

The default source directory src could not be found and no other directory has been specified through yarn.build in the workspace manifest.
and
The source directory configured through yarn.build in the project manifest does not exist.

Additional context
The zero-configuration approach worked really well for me before. It's a bit sad that more configuration is required now.

I'm also assuming the source directory is used to detect changes, which isn't ideal, as a lot of externous files in the project can have an impact on the compilation result (like package.json, tsconfig.json, ...). This would make me a lot less worried if we had #42 though 😀

I think you've got some good ideas here.

I also love the zero-config, or at least opinionated defaults.

Putting the folder config behind a flag is only temporary as I wasn't sure how much they may break things. I'm planning to get this all to a 1.0 around/near the end of the year.

I'm also assuming the source directory is used to detect changes, which isn't ideal, as a lot of externous files in the project can have an impact on the compilation result (like package.json, tsconfig.json, ...). This would make me a lot less worried if we had #42 though 😀

Yeah this is something I'm trying to work out the most ideal solution to. I think in most cases input: . and output: build, where input ends up being the whole package, the output is a folder inside the input folder (ie adjacent to src) is the best option.

In relation to the build cache, input is the folder to watch, and output is a folder to ignore.

As you said, files above src often affect the build, and should be included. I think setting input: . as a default is better than warning when src doesn't exist.

It's simpler to assume everything except the explicit output folder/artifact is part of the build.

In #45 I've updated the default to have input: . meaning the whole package directory minus build unless its reconfigured will be considered for the build cache.

I think this might solve your bug here, but let me know if it doesn't.

I also updated the readme to reflect what config is and isn't needed. The intention is unless you need something other than the default, you shouldn't need to drop config anywhere.

Yes, this is nice. Although now that I have the configuration, I like the idea that the build is ever so slightly faster because less files are checked.

Ultimately, I know when I have made too complicated changes and then I can just --ignore-cache.