-
Notifications
You must be signed in to change notification settings - Fork 34
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
Add an option to preserve assets in the output directory #1163
Conversation
🦋 Changeset detectedLatest commit: e9edc38 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
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.
LGTM 👍
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.
Lgtm otherwise nice one 🙏 @72636c you're probably more across this code
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.
This is great. I'd like to raise the skuba.config.ts
proposal for review but that can be a separate PR 👍
src/cli/build/assets.ts
Outdated
return; | ||
} | ||
|
||
const resolvedSrcDir = path.resolve(path.dirname(manifest.path), 'src'); |
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.
This is interesting as we haven't taken a strong opinion on src
within the tooling itself, it's just the templated default. Would it make sense for assets
to be specified relative to the parent directory (alongside package.json
)?
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've made the change here 3a6232e
(#1163). I think a better approach would be to use the directory from skuba.entryPoint
. What do you think?
This is needed for packages which ship Vocab translations, but can be useful for packages which publish CSS, images etc.
How it works
There's a new config key named
assets
:This will instruct skuba to copy the files matching the list of globs to the output directory/ies, preserving the directory structure from
src
:skuba build-package
it will copy them tolib-commonjs
andlib-es2015
skuba build
it will copy them tolib
Context behind this change
This came about when we started the work of compiling Metropolis packages. As part of that initiative, we've made some changes to Vocab. As of version 1.2.0 of the Webpack plugin, it can now process compiled code, meaning that it will look for
translations.json
files next to the generated compiled.vocab/index.ts
file.That means that consumers a package built with skuba (and SEEK has a few) will start seeing failing builds because the package does not ship
translations.json
files. This PR fixes that, but it is not the solution. Vocab was not meant to work with compiled code, but this will work for now. We'll need to revisit how Vocab works in the future.Some notes about this PR
There were a few threads on Slack with @askoufis, @72636c and @georgespyropoulos about the best way to do this. We decided to go with the simplest solution for now, which is to add a new
assets
key topackage.json#skuba
which will tell skuba which assets to copy to the output directory/ies. This is similar to howpackage.json#files
works.Currently, these's no documentation about this new feature, but we'll add it soon. What is the best place to document it? The
skuba
config is not documented anywhere at the moment. I thought about adding it inskuba init
and/orskuba configure
. @72636c suggested it might be time for a properskuba.config.ts
, especially if we want to support some defaults for Vocab.For now, you can see the tests for how it works.
When using
skuba build
with"build": "esbuild"
in theskuba
config, esbuild will not compile.vocab/index.ts
translation files generated by Vocab. That was a bit weird, so it must be something telling TypeScript/esbuild to ignore those files. I didn't dig deeper and it's unrelated to this PR, but something that would need to be addressed before the next major release when esbuild becomes the default. Edit: fixed in #1164