diff --git a/.eslintrc.js b/.eslintrc.cjs similarity index 91% rename from .eslintrc.js rename to .eslintrc.cjs index 401fd32ec..15b0ef8cd 100644 --- a/.eslintrc.js +++ b/.eslintrc.cjs @@ -91,6 +91,18 @@ module.exports = { browser: true } }, + { + // eslint is not great at detecting the esm/cjs context of a file, + // mistreating `require` and `module` globals as undefined + files: [ + 'packages/e2e-tests/_test_dependencies/cjs-only/**', + 'packages/e2e-tests/_test_dependencies/index-only/**', + 'packages/e2e-tests/_test_dependencies/vite-plugins/**' + ], + rules: { + 'no-undef': 'off' + } + }, { files: ['packages/e2e-tests/**/vite.config.js', 'packages/playground/**'], rules: { diff --git a/.prettierrc.js b/.prettierrc.js index 384f65f42..8b395011e 100644 --- a/.prettierrc.js +++ b/.prettierrc.js @@ -1,9 +1,10 @@ -module.exports = { +/** @type {import("prettier").Config} */ +export default { useTabs: true, singleQuote: true, trailingComma: 'none', printWidth: 100, - plugins: [require('prettier-plugin-svelte')], + plugins: ['prettier-plugin-svelte'], overrides: [ { files: '**/*.svx', diff --git a/package.json b/package.json index fa11620d2..77332b439 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,7 @@ { "name": "vite-plugin-svelte-monorepo", "private": true, + "type": "module", "scripts": { "test": "run-s -c test:unit test:build test:serve", "test:unit": "vitest run", diff --git a/packages/vite-plugin-svelte/src/utils/load-svelte-config.js b/packages/vite-plugin-svelte/src/utils/load-svelte-config.js index d3efd7a4b..e0bb20e1b 100644 --- a/packages/vite-plugin-svelte/src/utils/load-svelte-config.js +++ b/packages/vite-plugin-svelte/src/utils/load-svelte-config.js @@ -59,7 +59,8 @@ export async function loadSvelteConfig(viteConfig, inlineOptions) { // identify which require function to use (esm and cjs mode) const _require = import.meta.url ? esmRequire ?? (esmRequire = createRequire(import.meta.url)) - : require; + : // eslint-disable-next-line no-undef + require; // avoid loading cached version on reload delete _require.cache[_require.resolve(configFile)];