Skip to content

Commit

Permalink
fix: ignore @sveltejs/package and svelte2tsx for generated vite config (
Browse files Browse the repository at this point in the history
#711)

* fix: ignore @sveltejs/package and svelte2tsx for generated vite config

* chore: add missing import and use describe.runIf for dev/build only tests
  • Loading branch information
dominikg authored Aug 10, 2023
1 parent 8ade2dd commit 74cf82f
Show file tree
Hide file tree
Showing 7 changed files with 337 additions and 134 deletions.
5 changes: 5 additions & 0 deletions .changeset/six-cherries-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sveltejs/vite-plugin-svelte': patch
---

fix(config): ignore @sveltejs/package and svelte2tsx for optimizeDeps.include and ssr.noExternal generated config
35 changes: 35 additions & 0 deletions packages/e2e-tests/_test_dependencies/vite-plugins/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const path = require('path');
const fs = require('fs');
/**
* Ensure transform flow is not interrupted
* @returns {import('vite').Plugin[]}
Expand Down Expand Up @@ -39,3 +41,36 @@ function transformValidation() {
}

module.exports.transformValidation = transformValidation;

/**
* write resolved config
* @returns {import('vite').Plugin}
*/
function writeResolvedConfig() {
let cmd;
return {
name: 'writeResolvedConfig',
enforce: 'post',
config(_, { command }) {
cmd = command;
},
configResolved(config) {
function replacer(key, value) {
if (value instanceof RegExp) return value.toString();
else return value;
}
const serializableConfig = {
...config,
plugins: config.plugins.map((p) => p.name)
};
const dir = path.join(config.root, 'logs', 'resolved-configs');
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
const filename = path.join(dir, `vite.config.${cmd}${config.build.ssr ? '.ssr' : ''}.json`);
fs.writeFileSync(filename, JSON.stringify(serializableConfig, replacer, `\t`), 'utf-8');
}
};
}

module.exports.writeResolvedConfig = writeResolvedConfig;
Loading

0 comments on commit 74cf82f

Please sign in to comment.