Skip to content

Commit

Permalink
feat: adds support for svelte 5 (#963)
Browse files Browse the repository at this point in the history
## Description

- updates the svelte _compile_ call to include an empty object as a 2nd
parameter.
This is required for svelte 5 and svelte 4 seems to ignore it so it
seems we're in luck and don't need funky branching.
- Adjusts the supported compiler range for svelte
- Adjusts the  integration & unit tests to expect svelte 5 output

## Motivation and Context

Svelte 5 seems to have become stable and in their release notes they
encourage users to upgrade.

Also fixes #962 

## How Has This Been Tested?


- [x] green ci
- [x] adjusted  automated non-regression  tests

## Types of changes


- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] Documentation only change
- [ ] Refactor (non-breaking change which fixes an issue without
changing functionality)
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
  • Loading branch information
sverweij authored Nov 2, 2024
1 parent 7683e90 commit b473be5
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 317 deletions.
179 changes: 63 additions & 116 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
"npm-run-all": "4.1.5",
"prettier": "3.3.3",
"proxyquire": "2.1.3",
"svelte": "^4.2.19",
"svelte": "5.1.9",
"symlink-dir": "6.0.2",
"typescript": "5.6.3",
"upem": "9.0.4",
Expand Down Expand Up @@ -287,11 +287,6 @@
"package": "rechoir",
"policy": "wanted",
"because": "we want to keep rechoir ~similar to what webpack-cli uses (which is ^0.8.0 since 2022-11-15). See https://github.com/webpack/webpack-cli/blame/master/packages/webpack-cli/package.json"
},
{
"package": "svelte",
"policy": "wanted",
"because": "upgrading to supporting svelte 5 will require a non-trivial amount of labour (which we are going to invest, but not right now)"
}
]
},
Expand All @@ -303,7 +298,7 @@
"coffee-script": ">=1.0.0 <2.0.0",
"coffeescript": ">=1.0.0 <3.0.0",
"livescript": ">=1.0.0 <2.0.0",
"svelte": ">=3.0.0 <5.0.0",
"svelte": ">=3.0.0 <6.0.0",
"swc": ">=1.0.0 <2.0.0",
"typescript": ">=2.0.0 <6.0.0",
"vue-template-compiler": ">=2.0.0 <3.0.0",
Expand Down
6 changes: 5 additions & 1 deletion src/extract/transpile/svelte-wrap.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ function getTranspiler(pTranspilerWrapper) {
pTranspilerWrapper,
pTranspilerOptions,
);
return compile(lPreProcessedSource).js.code;
// in svelte 5 one must provide the second argument
// lest it throws because it's accessing a property
// in it. In svelte 4 (which also takes compiler
// options there) this isn't necessary.
return compile(lPreProcessedSource, {}).js.code;
};
}

Expand Down
2 changes: 1 addition & 1 deletion src/meta.cjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit b473be5

Please sign in to comment.