-
-
Notifications
You must be signed in to change notification settings - Fork 9k
feat(compiler-vapor): handle asset imports #13630
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
Merged
Changes from 6 commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
d0b7210
fix(vapor): Fix asset import from public directory.
Gianthard-cyh d50620c
test(compiler-vapor): add snapshot test for asset imports from public…
Gianthard-cyh 2b9f5fd
wip: avoid renderEffect and setProp.
Gianthard-cyh 6208852
wip: fix asset Url importing
Gianthard-cyh 2f99dc3
fix: srcset
Gianthard-cyh c5c45fd
Merge branch 'minor' into minor
Gianthard-cyh b8936ce
fix: remove redoundant vapor option.
Gianthard-cyh 0b68611
Merge branch 'minor' into minor
Gianthard-cyh 079bc73
Merge branch 'minor' into minor
Gianthard-cyh 18607b2
fix: utils.ts
Gianthard-cyh f63ad44
fix: lint
Gianthard-cyh 0ffc8a5
refactor: simplify expression handling
edison1105 44805ad
refactor: remove redundant code
edison1105 1cbc5ae
refactor: remove vapor option and related code
edison1105 09e66a4
refactor: update import handling and clean up unused code
edison1105 8747322
chore: revert unnecessary changes
edison1105 0467b95
refactor: enhance import expression handling in template generation
edison1105 473a74e
chore: Merge branch 'minor' into pr/Gianthard-cyh/13630
edison1105 3501d47
chore: update snap
edison1105 0e1921b
chore: Merge branch 'minor' into pr/Gianthard-cyh/13630
edison1105 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
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
134 changes: 134 additions & 0 deletions
134
.../compiler-vapor/__tests__/transforms/__snapshots__/templateTransformAssetUrl.spec.ts.snap
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,134 @@ | ||
| // Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html | ||
|
|
||
| exports[`compiler sfc: transform asset url > should allow for full base URLs, with paths 1`] = ` | ||
| "import { template as _template } from 'vue'; | ||
| const t0 = _template("<img src=\\"http://localhost:3000/src/logo.png\\">", true) | ||
|
|
||
| export function render(_ctx) { | ||
| const n0 = t0() | ||
| return n0 | ||
| }" | ||
| `; | ||
|
|
||
| exports[`compiler sfc: transform asset url > should allow for full base URLs, without paths 1`] = ` | ||
| "import { template as _template } from 'vue'; | ||
| const t0 = _template("<img src=\\"http://localhost:3000/logo.png\\">", true) | ||
|
|
||
| export function render(_ctx) { | ||
| const n0 = t0() | ||
| return n0 | ||
| }" | ||
| `; | ||
|
|
||
| exports[`compiler sfc: transform asset url > should allow for full base URLs, without port 1`] = ` | ||
| "import { template as _template } from 'vue'; | ||
| const t0 = _template("<img src=\\"http://localhost/logo.png\\">", true) | ||
|
|
||
| export function render(_ctx) { | ||
| const n0 = t0() | ||
| return n0 | ||
| }" | ||
| `; | ||
|
|
||
| exports[`compiler sfc: transform asset url > should allow for full base URLs, without protocol 1`] = ` | ||
| "import { template as _template } from 'vue'; | ||
| const t0 = _template("<img src=\\"//localhost/logo.png\\">", true) | ||
|
|
||
| export function render(_ctx) { | ||
| const n0 = t0() | ||
| return n0 | ||
| }" | ||
| `; | ||
|
|
||
| exports[`compiler sfc: transform asset url > support uri fragment 1`] = ` | ||
| "import { template as _template } from 'vue'; | ||
| import _imports_0 from '@svg/file.svg'; | ||
| const t0 = _template("<use href=\\"" + _imports_0 + '#fragment' + "\\"></use>") | ||
|
|
||
| export function render(_ctx) { | ||
| const n0 = t0() | ||
| const n1 = t0() | ||
| return [n0, n1] | ||
| }" | ||
| `; | ||
|
|
||
| exports[`compiler sfc: transform asset url > support uri is empty 1`] = ` | ||
| "import { template as _template } from 'vue'; | ||
| const t0 = _template("<use href=\\"\\"></use>", true) | ||
|
|
||
| export function render(_ctx) { | ||
| const n0 = t0() | ||
| return n0 | ||
| }" | ||
| `; | ||
|
|
||
| exports[`compiler sfc: transform asset url > transform assetUrls 1`] = ` | ||
| "import { template as _template } from 'vue'; | ||
| import _imports_0 from './logo.png'; | ||
| import _imports_1 from 'fixtures/logo.png'; | ||
| import _imports_2 from '/fixtures/logo.png'; | ||
| const t0 = _template("<img src=\\"" + _imports_0 + "\\">") | ||
| const t1 = _template("<img src=\\"" + _imports_1 + "\\">") | ||
| const t2 = _template("<img src=\\"http://example.com/fixtures/logo.png\\">") | ||
| const t3 = _template("<img src=\\"//example.com/fixtures/logo.png\\">") | ||
| const t4 = _template("<img src=\\"" + _imports_2 + "\\">") | ||
| const t5 = _template("<img src=\\"data:image/png;base64,i\\">") | ||
|
|
||
| export function render(_ctx) { | ||
| const n0 = t0() | ||
| const n1 = t1() | ||
| const n2 = t1() | ||
| const n3 = t2() | ||
| const n4 = t3() | ||
| const n5 = t4() | ||
| const n6 = t5() | ||
| return [n0, n1, n2, n3, n4, n5, n6] | ||
| }" | ||
| `; | ||
|
|
||
| exports[`compiler sfc: transform asset url > transform with stringify 1`] = ` | ||
| "import { template as _template } from 'vue'; | ||
| import _imports_0 from './bar.png'; | ||
| import _imports_1 from '/bar.png'; | ||
| const t0 = _template("<div><img src=\\"" + _imports_0 + "\\"><img src=\\"" + _imports_1 + "\\"><img src=\\"https://foo.bar/baz.png\\"><img src=\\"//foo.bar/baz.png\\"><img src=\\"" + _imports_0 + "\\"></div>", true) | ||
|
|
||
| export function render(_ctx) { | ||
| const n0 = t0() | ||
| return n0 | ||
| }" | ||
| `; | ||
|
|
||
| exports[`compiler sfc: transform asset url > with explicit base 1`] = ` | ||
| "import { template as _template } from 'vue'; | ||
| import _imports_0 from 'bar.png'; | ||
| import _imports_1 from '@theme/bar.png'; | ||
| const t0 = _template("<img src=\\"/foo/bar.png\\">") | ||
| const t1 = _template("<img src=\\"" + _imports_0 + "\\">") | ||
| const t2 = _template("<img src=\\"" + _imports_1 + "\\">") | ||
|
|
||
| export function render(_ctx) { | ||
| const n0 = t0() | ||
| const n1 = t1() | ||
| const n2 = t1() | ||
| const n3 = t2() | ||
| return [n0, n1, n2, n3] | ||
| }" | ||
| `; | ||
|
|
||
| exports[`compiler sfc: transform asset url > with includeAbsolute: true 1`] = ` | ||
| "import { template as _template } from 'vue'; | ||
| import _imports_0 from './bar.png'; | ||
| import _imports_1 from '/bar.png'; | ||
| const t0 = _template("<img src=\\"" + _imports_0 + "\\">") | ||
| const t1 = _template("<img src=\\"" + _imports_1 + "\\">") | ||
| const t2 = _template("<img src=\\"https://foo.bar/baz.png\\">") | ||
| const t3 = _template("<img src=\\"//foo.bar/baz.png\\">") | ||
|
|
||
| export function render(_ctx) { | ||
| const n0 = t0() | ||
| const n1 = t1() | ||
| const n2 = t2() | ||
| const n3 = t3() | ||
| return [n0, n1, n2, n3] | ||
| }" | ||
| `; |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.