-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
add: import decoded sourcemaps from SourceMapGenerator #5732
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
Merged
Conduitry
merged 6 commits into
sveltejs:master
from
milahu:add-import-SourceMapGenerator
Nov 30, 2020
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
9788885
add: import decoded sourcemaps from SourceMapGenerator
milahu 38a3eba
fix: remove dep source-map
milahu 19e42f7
fix: lowercase fn name, jsdoc comment
milahu 6311a85
fix: avoid f.apply, rename fn, optimize, prettify
milahu d8c553f
fix: snake case fns
milahu 484a04b
tidy
Conduitry File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import MagicString from 'magic-string'; | ||
import { SourceMapConsumer, SourceMapGenerator } from 'source-map'; | ||
|
||
export default { | ||
preprocess: { | ||
style: async ({ content, filename }) => { | ||
const src = new MagicString(content); | ||
const idx = content.indexOf('baritone'); | ||
src.overwrite(idx, idx+'baritone'.length, 'bar'); | ||
|
||
const map = SourceMapGenerator.fromSourceMap( | ||
await new SourceMapConsumer( | ||
// sourcemap must be encoded for SourceMapConsumer | ||
src.generateMap({ | ||
source: filename, | ||
hires: true, | ||
includeContent: false | ||
}) | ||
) | ||
); | ||
|
||
return { code: src.toString(), map }; | ||
} | ||
} | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<h1>Testing Styles</h1> | ||
<h2>Testing Styles 2</h2> | ||
<script>export const b = 2;</script> | ||
<style> | ||
h1 { | ||
--baritone: red; | ||
} | ||
|
||
h2 { | ||
--baz: blue; | ||
} | ||
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { test } from '../preprocessed-styles/test'; |
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.
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 think Conduitry was also asking if we could rename all the other variables and functions to use snake_case rather than camelCase
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.
good fight, good night
https://images-cdn.9gag.com/photo/a4ZXnVZ_700b.jpg
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'm not quite sure how to interpret. I guess you are going to bed. Will you rename the variables later?
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 pushed a commit to rename these and to also do some other tidying up and inlining of functions that are just called once. I'm aiming to merge this today and take a look for anything else screaming to be merged and then cut a release. Although this is technically a new feature, I'm thinking of still releasing this as a patch release.