chore: introduce linaria-scripts (SWC) #1131
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
Upgrading linaria to use modern tooling.
This is what you should pay attention for while reviewing this PR: https://github.com/callstack/linaria/pull/1131/files#diff-df46b0b81d593e59747fa15f319c82ed21bb76d5c6a7c91ce670a027904bcdd0
Summary
Implmeneted custom build script based on SWC. Inspired by astro-scripts..
SWC builds ~10x faster than babel. However, most of build time is consumed by typescript compilier.
I combined TSC and SWC compilier in one script to save time on unwatned spawning of new processes.
Also, changed all output to /dist, (/dist/cjs, /dist/esm, /dist/types) because I believe it's more convinient way to manage output artifacts.
TODO: I also suggest to change output file extensions: .mjs for esm and .cjs for cjs output. I think it's generally good practice.
Almost all tests are passing, however, related to processing expression from imported dependencies are failing, because @linaria/shaker can't understand export syntax of some files (especially @linaria/utils/index.js).
Compare Babel exports:
and SWC exports:
I identified out cause of fail.
File processed by babel and loaded by import-exports collector:
Same file processed by SWC:
Test plan
Write test for different bundlers I suppose?...
Or change library architecture.
This depends on: #1128