-
Notifications
You must be signed in to change notification settings - Fork 1k
[lit-labs/compiler] rollup example and source map tests #4077
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
Conversation
🦋 Changeset detectedLatest commit: 5b1c2db The changes in this PR will be included in the next version bump. This PR includes changesets to release 0 packagesWhen changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types 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 |
📊 Tachometer Benchmark ResultsSummarynop-update
render
update
update-reflect
Resultsthis-change
render
update
update-reflect
this-change, tip-of-tree, previous-release
render
update
nop-update
this-change, tip-of-tree, previous-release
render
update
this-change, tip-of-tree, previous-release
render
update
update-reflect
|
| }; | ||
|
|
||
| test('basic.ts', async () => { | ||
| const smc = await setupTest('basic.js.map'); |
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.
probably not a big deal with a single file test like this but maybe it's worth putting this in a suiteSetup() and using suiteTeardown() to call smc.destroy()?
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.
Great catch. This is a small test so I think I'm inclined to add the smc.destroy() directly to the end of the test.
I tried adding a test.after.each which cleans up the smc, but noted that if the destructor throws outside the test, we get a 0/1 tests passed with an exit code of 0 – which makes it look like everything worked. Went with simpler approach which doesn't have this strange issue.
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.
since all the assertions are synchronous it's probably fine as is, though something about test code execution ordering makes me a bit uncomfortable.
how about something like this?
c516966
this seems to work on my end. is there an actual chance that .destroy() would fail? and should that then report as a test failure?
if so we can add try catch like this https://github.com/google/wireit/blob/df9c9e9d3dc4bd1c92933ef6d4e1919679390478/src/test/analysis.test.ts#L27-L34
|
Thank you for the excellent suggestions! |
|
I did some further investigating regarding the license falling below the imports in the generated source_map javascript file. That looks like a rollup/plugin-typescript behavior – as it occurs without the compiler transform. I'll add a license golden (in a separate PR) to the test_files to show that the compiler transform doesn't do this by default. |
augustjk
left a comment
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.
suggestion #4077 (comment) is optional.
excellent addition of rollup example and making sure generated source maps are accurate!
Issue: #189
RFC: lit/rfcs#21
Full prototype PR: #3984
Why
The initial labs compiler public export is only a TypeScript transform. This makes it usable within multiple build tools that accept TypeScript transformers. E.g., within g3,
@rollup/plugin-typescript,ttypescript, and maybe one day natively through TypeScript.This PR adds an example rollup config for testing source maps. The example rollup config uses
@rollup/plugin-typescriptto compile the sourcemap test file. A new test has been added to ensure the resulting source maps correctly reference the authored example.How
source-mapwhich allows easy queries on a source map, and manually setup some source map tests.rollup.source_map_tests.jsconfig which uses the compiler transform to compile a basic typescript file for source map testing.Risk
This change has minimal risks as it doesn't add or change any logic in the compiler, it's a test only and example only change.
Because labs/compiler uses TypeScript 5, while the rest of the monorepo uses TypeScript 4. This will also come in a followup, and can use the example rollup config here as inspiration.
Notes
I noticed in this change that the license does not remain at the top of the generated
basic.jsfile. This will be addressed in a followup.