-
Notifications
You must be signed in to change notification settings - Fork 93
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
Support transformations with --stub
mode
#271
Comments
Hi. It is an expected limitation of passive stubs since we do not build or bundle any of the source code to be able to rewrite them. We might think about a custom jiti plugin btw and add it to default stubs |
unbuild --stub
ignores the replace option (replace import.meta.vitest
with 'undefined')--stub
mode
@jacob-8 fwiw after reading the source a bit I was able to add some of this functionality. There is an undocumented property of the jiti options: It feels kinda hacky but it does work. |
Update: In our case we needed to transform import jiti from "file:///Users/justinschroeder/Projects/formkit/node_modules/.pnpm/jiti@1.21.0/node_modules/jiti/lib/index.js";
/** @type {import("/Users/justinschroeder/Projects/formkit/packages/core/src/index")} */
const _module = jiti(null, {
"esmResolve": true,
"interopDefault": true,
"transformOptions": {
"babel": {
"plugins": [
[
require('babel-plugin-transform-import-meta-x'),
{ replacements: { 'hot': '({ on: () => {} })' } },
],
[
require('babel-plugin-transform-replace-expressions'),
{ replace: { __DEV__: 'true' } },
],
],
},
},
"cache": '.jiti-cache',
"alias": {
"@formkit/core": "/Users/justinschroeder/Projects/formkit/packages/core"
}
})("/Users/justinschroeder/Projects/formkit/packages/core/src/index.ts"); Bit of a bear to get the stubs to look like that, but it seems #368 could be helpful in this regard. |
@justin-schroeder feel free to open an issue in jiti, i think we can have |
Babel plugin support landed via #368 I still love to track any fixes in jiti directly btw if someone can make a tracker 🙏🏼 |
Environment
node 18.12.1
Windows 11
pnpm 8.6.0
Reproduction
pnpm install
pnpm -F svelte-scoped stub
(if we instead runpnpm -F svelte-scoped build
at this point, there will be no error later)cd examples/svelte-scoped
pnpm install
pnpm dev
to see the errorSorry the repro is full-blown and not minimal. I'm mostly posting this to see if the problem is already known and has a workaround. If not and the big repo is a hassle, let me know if you want a minimal repro.
Describe the bug
I'm using inline testing from Vitest and as directed in https://vitest.dev/guide/in-source.html#other-bundlers I have added the following to my
build.config.ts
:When I build the
svelte-scoped
package and consume it an example project in a separate folder there are no problems. However, when I try to stub and then start the project up I get this error:Additional context
No response
Logs
No response
The text was updated successfully, but these errors were encountered: