vite-plugin-solid 2.8.2 → 2.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -1
- package/dist/cjs/index.cjs +56 -32
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/esm/index.mjs +37 -32
- package/dist/esm/index.mjs.map +1 -1
- package/dist/types/index.d.ts +2 -114
- package/package.json +8 -3
package/README.md
CHANGED
|
@@ -188,7 +188,7 @@ if (import.meta.hot) {
|
|
|
188
188
|
|
|
189
189
|
- If one of your dependency spit out React code instead of Solid that means that they don't expose JSX properly. To get around it, you might want to manually exclude it from the [dependencies optimization](https://vitejs.dev/config/dep-optimization-options.html#optimizedeps-exclude)
|
|
190
190
|
|
|
191
|
-
- If you are trying to make [directives](https://www.solidjs.com/docs/latest/api#use%3A___) work and they somehow don't try setting the `options.typescript.onlyRemoveTypeImports` option to `true`
|
|
191
|
+
- If you are trying to make [directives](https://www.solidjs.com/docs/latest/api#use%3A___) work, and they somehow don't try setting the `options.typescript.onlyRemoveTypeImports` option to `true`
|
|
192
192
|
|
|
193
193
|
## Migration from v1
|
|
194
194
|
|
|
@@ -198,6 +198,10 @@ The main breaking change from previous version is that the package has been rena
|
|
|
198
198
|
|
|
199
199
|
For other breaking changes, check [the migration guide of vite](https://vitejs.dev/guide/migration.html).
|
|
200
200
|
|
|
201
|
+
# Testing
|
|
202
|
+
|
|
203
|
+
If you are using [vitest](https://vitest.dev/), this plugin already injects the necessary configuration for you. It even automatically detects if you have `@testing-library/jest-dom` installed in your project and automatically adds it to the `setupFiles`. All you need to add (if you want) is `globals`, `coverage`, and other testing configuration of your choice. If you can live without those, enjoy using vitest without the need to configure it yourself.
|
|
204
|
+
|
|
201
205
|
# Credits
|
|
202
206
|
|
|
203
207
|
- [solid-js](https://github.com/solidjs/solid)
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
var ts = require('@babel/preset-typescript');
|
|
3
|
+
var babel = require('@babel/core');
|
|
5
4
|
var solid = require('babel-preset-solid');
|
|
6
5
|
var fs = require('fs');
|
|
7
6
|
var mergeAnything = require('merge-anything');
|
|
@@ -11,6 +10,25 @@ var vite = require('vite');
|
|
|
11
10
|
var vitefu = require('vitefu');
|
|
12
11
|
|
|
13
12
|
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
13
|
+
function _interopNamespaceDefault(e) {
|
|
14
|
+
var n = Object.create(null);
|
|
15
|
+
if (e) {
|
|
16
|
+
Object.keys(e).forEach(function (k) {
|
|
17
|
+
if (k !== 'default') {
|
|
18
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return e[k]; }
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
n.default = e;
|
|
27
|
+
return Object.freeze(n);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var babel__namespace = /*#__PURE__*/_interopNamespaceDefault(babel);
|
|
31
|
+
|
|
14
32
|
const require$1 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
15
33
|
const runtimePublicPath = '/@solid-refresh';
|
|
16
34
|
const runtimeFilePath = require$1.resolve('solid-refresh/dist/solid-refresh.mjs');
|
|
@@ -34,9 +52,10 @@ function containsSolidField(fields) {
|
|
|
34
52
|
return false;
|
|
35
53
|
}
|
|
36
54
|
function getJestDomExport(setupFiles) {
|
|
37
|
-
return
|
|
55
|
+
return setupFiles?.some(path => /jest-dom/.test(path)) ? undefined : ['@testing-library/jest-dom/vitest', '@testing-library/jest-dom/extend-expect'].find(path => {
|
|
38
56
|
try {
|
|
39
|
-
require$1(path);
|
|
57
|
+
require$1.resolve(path);
|
|
58
|
+
return true;
|
|
40
59
|
} catch (e) {
|
|
41
60
|
return false;
|
|
42
61
|
}
|
|
@@ -70,16 +89,20 @@ function solidPlugin(options = {}) {
|
|
|
70
89
|
// fix for bundling dev in production
|
|
71
90
|
const nestedDeps = replaceDev ? ['solid-js', 'solid-js/web', 'solid-js/store', 'solid-js/html', 'solid-js/h'] : [];
|
|
72
91
|
const test = userConfig.test || {};
|
|
73
|
-
|
|
74
|
-
// to simplify the processing of the config, we normalize the setupFiles to an array
|
|
75
|
-
const userSetupFiles = typeof test.setupFiles === 'string' ? [test.setupFiles] : test.setupFiles || [];
|
|
76
92
|
if (userConfig.mode === 'test') {
|
|
93
|
+
// to simplify the processing of the config, we normalize the setupFiles to an array
|
|
94
|
+
const userSetupFiles = typeof test.setupFiles === 'string' ? [test.setupFiles] : test.setupFiles || [];
|
|
77
95
|
if (!test.environment && !options.ssr) {
|
|
78
96
|
test.environment = 'jsdom';
|
|
79
97
|
}
|
|
98
|
+
test.server = test.server || {};
|
|
99
|
+
test.server.deps = test.server.deps || {};
|
|
100
|
+
if (!test.server.deps.inline?.find(item => /solid-js/.test(item.toString()))) {
|
|
101
|
+
test.server.deps.inline = [...(test.server.deps.inline || []), /solid-js/];
|
|
102
|
+
}
|
|
80
103
|
const jestDomImport = getJestDomExport(userSetupFiles);
|
|
81
104
|
if (jestDomImport) {
|
|
82
|
-
test.setupFiles = [...userSetupFiles,
|
|
105
|
+
test.setupFiles = [...userSetupFiles, jestDomImport];
|
|
83
106
|
}
|
|
84
107
|
}
|
|
85
108
|
return {
|
|
@@ -87,9 +110,7 @@ function solidPlugin(options = {}) {
|
|
|
87
110
|
* We only need esbuild on .ts or .js files.
|
|
88
111
|
* .tsx & .jsx files are handled by us
|
|
89
112
|
*/
|
|
90
|
-
esbuild: {
|
|
91
|
-
include: /\.ts$/
|
|
92
|
-
},
|
|
113
|
+
// esbuild: { include: /\.ts$/ },
|
|
93
114
|
resolve: {
|
|
94
115
|
conditions: ['solid', ...(replaceDev ? ['development'] : []), ...(userConfig.mode === 'test' && !options.ssr ? ['browser'] : [])],
|
|
95
116
|
dedupe: nestedDeps,
|
|
@@ -103,7 +124,7 @@ function solidPlugin(options = {}) {
|
|
|
103
124
|
exclude: solidPkgsConfig.optimizeDeps.exclude
|
|
104
125
|
},
|
|
105
126
|
ssr: solidPkgsConfig.ssr,
|
|
106
|
-
...(test ? {
|
|
127
|
+
...(test.server ? {
|
|
107
128
|
test
|
|
108
129
|
} : {})
|
|
109
130
|
};
|
|
@@ -120,11 +141,11 @@ function solidPlugin(options = {}) {
|
|
|
120
141
|
async transform(source, id, transformOptions) {
|
|
121
142
|
const isSsr = transformOptions && transformOptions.ssr;
|
|
122
143
|
const currentFileExtension = getExtension(id);
|
|
123
|
-
const extensionsToWatch =
|
|
144
|
+
const extensionsToWatch = options.extensions || [];
|
|
124
145
|
const allExtensions = extensionsToWatch.map(extension =>
|
|
125
146
|
// An extension can be a string or a tuple [extension, options]
|
|
126
147
|
typeof extension === 'string' ? extension : extension[0]);
|
|
127
|
-
if (!filter(id) || !allExtensions.includes(currentFileExtension)) {
|
|
148
|
+
if (!filter(id) || !(/\.[mc]?[tj]sx$/i.test(id) || allExtensions.includes(currentFileExtension))) {
|
|
128
149
|
return null;
|
|
129
150
|
}
|
|
130
151
|
const inNodeModules = /node_modules/.test(id);
|
|
@@ -148,9 +169,21 @@ function solidPlugin(options = {}) {
|
|
|
148
169
|
};
|
|
149
170
|
}
|
|
150
171
|
id = id.replace(/\?.+$/, '');
|
|
172
|
+
|
|
173
|
+
// We need to know if the current file extension has a typescript options tied to it
|
|
174
|
+
const shouldBeProcessedWithTypescript = /\.[mc]?tsx$/i.test(id) || extensionsToWatch.some(extension => {
|
|
175
|
+
if (typeof extension === 'string') {
|
|
176
|
+
return extension.includes('tsx');
|
|
177
|
+
}
|
|
178
|
+
const [extensionName, extensionOptions] = extension;
|
|
179
|
+
if (extensionName !== currentFileExtension) return false;
|
|
180
|
+
return extensionOptions.typescript;
|
|
181
|
+
});
|
|
182
|
+
const plugins = ['jsx'];
|
|
183
|
+
if (shouldBeProcessedWithTypescript) {
|
|
184
|
+
plugins.push('typescript');
|
|
185
|
+
}
|
|
151
186
|
const opts = {
|
|
152
|
-
babelrc: false,
|
|
153
|
-
configFile: false,
|
|
154
187
|
root: projectRoot,
|
|
155
188
|
filename: id,
|
|
156
189
|
sourceFileName: id,
|
|
@@ -161,23 +194,14 @@ function solidPlugin(options = {}) {
|
|
|
161
194
|
plugins: needHmr && !isSsr && !inNodeModules ? [[solidRefresh, {
|
|
162
195
|
bundler: 'vite'
|
|
163
196
|
}]] : [],
|
|
197
|
+
ast: false,
|
|
164
198
|
sourceMaps: true,
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
// We need to know if the current file extension has a typescript options tied to it
|
|
170
|
-
const shouldBeProcessedWithTypescript = extensionsToWatch.some(extension => {
|
|
171
|
-
if (typeof extension === 'string') {
|
|
172
|
-
return extension.includes('tsx');
|
|
199
|
+
configFile: false,
|
|
200
|
+
babelrc: false,
|
|
201
|
+
parserOpts: {
|
|
202
|
+
plugins
|
|
173
203
|
}
|
|
174
|
-
|
|
175
|
-
if (extensionName !== currentFileExtension) return false;
|
|
176
|
-
return extensionOptions.typescript;
|
|
177
|
-
});
|
|
178
|
-
if (shouldBeProcessedWithTypescript) {
|
|
179
|
-
opts.presets.push([ts, options.typescript || {}]);
|
|
180
|
-
}
|
|
204
|
+
};
|
|
181
205
|
|
|
182
206
|
// Default value for babel user options
|
|
183
207
|
let babelUserOptions = {};
|
|
@@ -193,7 +217,7 @@ function solidPlugin(options = {}) {
|
|
|
193
217
|
const {
|
|
194
218
|
code,
|
|
195
219
|
map
|
|
196
|
-
} = await
|
|
220
|
+
} = await babel__namespace.transformAsync(source, babelOptions);
|
|
197
221
|
return {
|
|
198
222
|
code,
|
|
199
223
|
map
|
package/dist/cjs/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","sources":["../../src/index.ts"],"sourcesContent":["import { transformAsync, TransformOptions } from '@babel/core';\nimport ts from '@babel/preset-typescript';\nimport solid from 'babel-preset-solid';\nimport { readFileSync } from 'fs';\nimport { mergeAndConcat } from 'merge-anything';\nimport { createRequire } from 'module';\nimport solidRefresh from 'solid-refresh/babel';\nimport { createFilter } from 'vite';\nimport type { Alias, AliasOptions, Plugin, FilterPattern } from 'vite';\nimport { crawlFrameworkPkgs } from 'vitefu';\n\nconst require = createRequire(import.meta.url);\n\nconst runtimePublicPath = '/@solid-refresh';\nconst runtimeFilePath = require.resolve('solid-refresh/dist/solid-refresh.mjs');\nconst runtimeCode = readFileSync(runtimeFilePath, 'utf-8');\n\n/** Possible options for the extensions property */\nexport interface ExtensionOptions {\n typescript?: boolean;\n}\n\n/** Configuration options for vite-plugin-solid. */\nexport interface Options {\n /**\n * A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files\n * the plugin should operate on.\n */\n include?: FilterPattern;\n /**\n * A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files\n * to be ignored by the plugin.\n */\n exclude?: FilterPattern;\n /**\n * This will inject solid-js/dev in place of solid-js in dev mode. Has no\n * effect in prod. If set to `false`, it won't inject it in dev. This is\n * useful for extra logs and debugging.\n *\n * @default true\n */\n dev: boolean;\n /**\n * This will force SSR code in the produced files. This is experiemental\n * and mostly not working yet.\n *\n * @default false\n */\n ssr: boolean;\n\n /**\n * This will inject HMR runtime in dev mode. Has no effect in prod. If\n * set to `false`, it won't inject the runtime in dev.\n *\n * @default true\n */\n hot: boolean;\n /**\n * This registers additional extensions that should be processed by\n * vite-plugin-solid.\n *\n * @default undefined\n */\n extensions?: (string | [string, ExtensionOptions])[];\n /**\n * Pass any additional babel transform options. They will be merged with\n * the transformations required by Solid.\n *\n * @default {}\n */\n babel:\n | TransformOptions\n | ((source: string, id: string, ssr: boolean) => TransformOptions)\n | ((source: string, id: string, ssr: boolean) => Promise<TransformOptions>);\n typescript: {\n /**\n * Forcibly enables jsx parsing. Otherwise angle brackets will be treated as\n * typescript's legacy type assertion var foo = <string>bar;. Also, isTSX:\n * true requires allExtensions: true.\n *\n * @default false\n */\n isTSX?: boolean;\n\n /**\n * Replace the function used when compiling JSX expressions. This is so that\n * we know that the import is not a type import, and should not be removed.\n *\n * @default React\n */\n jsxPragma?: string;\n\n /**\n * Replace the function used when compiling JSX fragment expressions. This\n * is so that we know that the import is not a type import, and should not\n * be removed.\n *\n * @default React.Fragment\n */\n jsxPragmaFrag?: string;\n\n /**\n * Indicates that every file should be parsed as TS or TSX (depending on the\n * isTSX option).\n *\n * @default false\n */\n allExtensions?: boolean;\n\n /**\n * Enables compilation of TypeScript namespaces.\n *\n * @default uses the default set by @babel/plugin-transform-typescript.\n */\n allowNamespaces?: boolean;\n\n /**\n * When enabled, type-only class fields are only removed if they are\n * prefixed with the declare modifier:\n *\n * > NOTE: This will be enabled by default in Babel 8\n *\n * @default false\n *\n * @example\n * ```ts\n * class A {\n * declare foo: string; // Removed\n * bar: string; // Initialized to undefined\n * prop?: string; // Initialized to undefined\n * prop1!: string // Initialized to undefined\n * }\n * ```\n */\n allowDeclareFields?: boolean;\n\n /**\n * When set to true, the transform will only remove type-only imports\n * (introduced in TypeScript 3.8). This should only be used if you are using\n * TypeScript >= 3.8.\n *\n * @default false\n */\n onlyRemoveTypeImports?: boolean;\n\n /**\n * When set to true, Babel will inline enum values rather than using the\n * usual enum output:\n *\n * This option differs from TypeScript's --isolatedModules behavior, which\n * ignores the const modifier and compiles them as normal enums, and aligns\n * Babel's behavior with TypeScript's default behavior.\n *\n * ```ts\n * // Input\n * const enum Animals {\n * Fish\n * }\n * console.log(Animals.Fish);\n *\n * // Default output\n * var Animals;\n *\n * (function (Animals) {\n * Animals[Animals[\"Fish\"] = 0] = \"Fish\";\n * })(Animals || (Animals = {}));\n *\n * console.log(Animals.Fish);\n *\n * // `optimizeConstEnums` output\n * console.log(0);\n * ```\n *\n * However, when exporting a const enum Babel will compile it to a plain\n * object literal so that it doesn't need to rely on cross-file analysis\n * when compiling it:\n *\n * ```ts\n * // Input\n * export const enum Animals {\n * Fish,\n * }\n *\n * // `optimizeConstEnums` output\n * export var Animals = {\n * Fish: 0,\n * };\n * ```\n *\n * @default false\n */\n optimizeConstEnums?: boolean;\n };\n /**\n * Pass any additional [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/tree/main/packages/babel-plugin-jsx-dom-expressions#plugin-options).\n * They will be merged with the defaults sets by [babel-preset-solid](https://github.com/solidjs/solid/blob/main/packages/babel-preset-solid/index.js#L8-L25).\n *\n * @default {}\n */\n solid: {\n /**\n * Removed unnecessary closing tags from template strings. More info here:\n * https://github.com/solidjs/solid/blob/main/CHANGELOG.md#smaller-templates\n *\n * @default false\n */\n omitNestedClosingTags: boolean;\n\n /**\n * The name of the runtime module to import the methods from.\n *\n * @default \"solid-js/web\"\n */\n moduleName?: string;\n\n /**\n * The output mode of the compiler.\n * Can be:\n * - \"dom\" is standard output\n * - \"ssr\" is for server side rendering of strings.\n * - \"universal\" is for using custom renderers from solid-js/universal\n *\n * @default \"dom\"\n */\n generate?: 'ssr' | 'dom' | 'universal';\n\n /**\n * Indicate whether the output should contain hydratable markers.\n *\n * @default false\n */\n hydratable?: boolean;\n\n /**\n * Boolean to indicate whether to enable automatic event delegation on camelCase.\n *\n * @default true\n */\n delegateEvents?: boolean;\n\n /**\n * Boolean indicates whether smart conditional detection should be used.\n * This optimizes simple boolean expressions and ternaries in JSX.\n *\n * @default true\n */\n wrapConditionals?: boolean;\n\n /**\n * Boolean indicates whether to set current render context on Custom Elements and slots.\n * Useful for seemless Context API with Web Components.\n *\n * @default true\n */\n contextToCustomElements?: boolean;\n\n /**\n * Array of Component exports from module, that aren't included by default with the library.\n * This plugin will automatically import them if it comes across them in the JSX.\n *\n * @default [\"For\",\"Show\",\"Switch\",\"Match\",\"Suspense\",\"SuspenseList\",\"Portal\",\"Index\",\"Dynamic\",\"ErrorBoundary\"]\n */\n builtIns?: string[];\n };\n}\n\nfunction getExtension(filename: string): string {\n const index = filename.lastIndexOf('.');\n return index < 0 ? '' : filename.substring(index).replace(/\\?.+$/, '');\n}\nfunction containsSolidField(fields: Record<string, any>) {\n const keys = Object.keys(fields);\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n if (key === 'solid') return true;\n if (typeof fields[key] === 'object' && fields[key] != null && containsSolidField(fields[key]))\n return true;\n }\n return false;\n}\n\nfunction getJestDomExport(setupFiles: string[]) {\n return (setupFiles || []).some((path) => /jest-dom/.test(path))\n ? undefined\n : ['@testing-library/jest-dom/vitest', '@testing-library/jest-dom/extend-expect'].find(\n (path) => {\n try {\n require(path);\n } catch (e) {\n return false;\n }\n },\n );\n}\n\nexport default function solidPlugin(options: Partial<Options> = {}): Plugin {\n const filter = createFilter(options.include, options.exclude);\n\n let needHmr = false;\n let replaceDev = false;\n let projectRoot = process.cwd();\n\n return {\n name: 'solid',\n enforce: 'pre',\n\n async config(userConfig, { command }) {\n // We inject the dev mode only if the user explicitely wants it or if we are in dev (serve) mode\n replaceDev = options.dev === true || (options.dev !== false && command === 'serve');\n projectRoot = userConfig.root;\n\n if (!userConfig.resolve) userConfig.resolve = {};\n userConfig.resolve.alias = normalizeAliases(userConfig.resolve && userConfig.resolve.alias);\n\n const solidPkgsConfig = await crawlFrameworkPkgs({\n viteUserConfig: userConfig,\n root: projectRoot || process.cwd(),\n isBuild: command === 'build',\n isFrameworkPkgByJson(pkgJson) {\n return containsSolidField(pkgJson.exports || {});\n },\n });\n\n // fix for bundling dev in production\n const nestedDeps = replaceDev\n ? ['solid-js', 'solid-js/web', 'solid-js/store', 'solid-js/html', 'solid-js/h']\n : [];\n\n const test = (userConfig as any).test || {};\n\n // to simplify the processing of the config, we normalize the setupFiles to an array\n const userSetupFiles: string[] =\n typeof test.setupFiles === 'string' ? [test.setupFiles] : test.setupFiles || [];\n\n if (userConfig.mode === 'test') {\n if (!test.environment && !options.ssr) {\n test.environment = 'jsdom';\n }\n\n const jestDomImport = getJestDomExport(userSetupFiles);\n\n if (jestDomImport) {\n test.setupFiles = [...userSetupFiles, require.resolve(jestDomImport)];\n }\n }\n\n return {\n /**\n * We only need esbuild on .ts or .js files.\n * .tsx & .jsx files are handled by us\n */\n esbuild: { include: /\\.ts$/ },\n resolve: {\n conditions: [\n 'solid',\n ...(replaceDev ? ['development'] : []),\n ...(userConfig.mode === 'test' && !options.ssr ? ['browser'] : []),\n ],\n dedupe: nestedDeps,\n alias: [{ find: /^solid-refresh$/, replacement: runtimePublicPath }],\n },\n optimizeDeps: {\n include: [...nestedDeps, ...solidPkgsConfig.optimizeDeps.include],\n exclude: solidPkgsConfig.optimizeDeps.exclude,\n },\n ssr: solidPkgsConfig.ssr,\n ...(test ? { test } : {}),\n };\n },\n\n configResolved(config) {\n needHmr = config.command === 'serve' && config.mode !== 'production' && options.hot !== false;\n },\n\n resolveId(id) {\n if (id === runtimePublicPath) return id;\n },\n\n load(id) {\n if (id === runtimePublicPath) return runtimeCode;\n },\n\n async transform(source, id, transformOptions) {\n const isSsr = transformOptions && transformOptions.ssr;\n const currentFileExtension = getExtension(id);\n\n const extensionsToWatch = [...(options.extensions || []), '.tsx', '.jsx'];\n const allExtensions = extensionsToWatch.map((extension) =>\n // An extension can be a string or a tuple [extension, options]\n typeof extension === 'string' ? extension : extension[0],\n );\n\n if (!filter(id) || !allExtensions.includes(currentFileExtension)) {\n return null;\n }\n\n const inNodeModules = /node_modules/.test(id);\n\n let solidOptions: { generate: 'ssr' | 'dom'; hydratable: boolean };\n\n if (options.ssr) {\n if (isSsr) {\n solidOptions = { generate: 'ssr', hydratable: true };\n } else {\n solidOptions = { generate: 'dom', hydratable: true };\n }\n } else {\n solidOptions = { generate: 'dom', hydratable: false };\n }\n\n id = id.replace(/\\?.+$/, '');\n\n const opts: TransformOptions = {\n babelrc: false,\n configFile: false,\n root: projectRoot,\n filename: id,\n sourceFileName: id,\n presets: [[solid, { ...solidOptions, ...(options.solid || {}) }]],\n plugins: needHmr && !isSsr && !inNodeModules ? [[solidRefresh, { bundler: 'vite' }]] : [],\n sourceMaps: true,\n // Vite handles sourcemap flattening\n inputSourceMap: false as any,\n };\n\n // We need to know if the current file extension has a typescript options tied to it\n const shouldBeProcessedWithTypescript = extensionsToWatch.some((extension) => {\n if (typeof extension === 'string') {\n return extension.includes('tsx');\n }\n\n const [extensionName, extensionOptions] = extension;\n if (extensionName !== currentFileExtension) return false;\n\n return extensionOptions.typescript;\n });\n\n if (shouldBeProcessedWithTypescript) {\n opts.presets.push([ts, options.typescript || {}]);\n }\n\n // Default value for babel user options\n let babelUserOptions: TransformOptions = {};\n\n if (options.babel) {\n if (typeof options.babel === 'function') {\n const babelOptions = options.babel(source, id, isSsr);\n babelUserOptions = babelOptions instanceof Promise ? await babelOptions : babelOptions;\n } else {\n babelUserOptions = options.babel;\n }\n }\n\n const babelOptions = mergeAndConcat(babelUserOptions, opts) as TransformOptions;\n\n const { code, map } = await transformAsync(source, babelOptions);\n\n return { code, map };\n },\n };\n}\n\n/**\n * This basically normalize all aliases of the config into\n * the array format of the alias.\n *\n * eg: alias: { '@': 'src/' } => [{ find: '@', replacement: 'src/' }]\n */\nfunction normalizeAliases(alias: AliasOptions = []): Alias[] {\n return Array.isArray(alias)\n ? alias\n : Object.entries(alias).map(([find, replacement]) => ({ find, replacement }));\n}\n"],"names":["require","createRequire","import","runtimePublicPath","runtimeFilePath","resolve","runtimeCode","readFileSync","getExtension","filename","index","lastIndexOf","substring","replace","containsSolidField","fields","keys","Object","i","length","key","getJestDomExport","setupFiles","some","path","test","undefined","find","e","solidPlugin","options","filter","createFilter","include","exclude","needHmr","replaceDev","projectRoot","process","cwd","name","enforce","config","userConfig","command","dev","root","alias","normalizeAliases","solidPkgsConfig","crawlFrameworkPkgs","viteUserConfig","isBuild","isFrameworkPkgByJson","pkgJson","exports","nestedDeps","userSetupFiles","mode","environment","ssr","jestDomImport","esbuild","conditions","dedupe","replacement","optimizeDeps","configResolved","hot","resolveId","id","load","transform","source","transformOptions","isSsr","currentFileExtension","extensionsToWatch","extensions","allExtensions","map","extension","includes","inNodeModules","solidOptions","generate","hydratable","opts","babelrc","configFile","sourceFileName","presets","solid","plugins","solidRefresh","bundler","sourceMaps","inputSourceMap","shouldBeProcessedWithTypescript","extensionName","extensionOptions","typescript","push","ts","babelUserOptions","babel","babelOptions","Promise","mergeAndConcat","code","transformAsync","Array","isArray","entries"],"mappings":";;;;;;;;;;;;;AAWA,MAAMA,SAAO,GAAGC,sBAAa,CAACC,8LAAe,CAAC,CAAA;AAE9C,MAAMC,iBAAiB,GAAG,iBAAiB,CAAA;AAC3C,MAAMC,eAAe,GAAGJ,SAAO,CAACK,OAAO,CAAC,sCAAsC,CAAC,CAAA;AAC/E,MAAMC,WAAW,GAAGC,eAAY,CAACH,eAAe,EAAE,OAAO,CAAC,CAAA;;AAE1D;;AAKA;;AAoPA,SAASI,YAAYA,CAACC,QAAgB,EAAU;AAC9C,EAAA,MAAMC,KAAK,GAAGD,QAAQ,CAACE,WAAW,CAAC,GAAG,CAAC,CAAA;AACvC,EAAA,OAAOD,KAAK,GAAG,CAAC,GAAG,EAAE,GAAGD,QAAQ,CAACG,SAAS,CAACF,KAAK,CAAC,CAACG,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;AACxE,CAAA;AACA,SAASC,kBAAkBA,CAACC,MAA2B,EAAE;AACvD,EAAA,MAAMC,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACD,MAAM,CAAC,CAAA;AAChC,EAAA,KAAK,IAAIG,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,IAAI,CAACG,MAAM,EAAED,CAAC,EAAE,EAAE;AACpC,IAAA,MAAME,GAAG,GAAGJ,IAAI,CAACE,CAAC,CAAC,CAAA;AACnB,IAAA,IAAIE,GAAG,KAAK,OAAO,EAAE,OAAO,IAAI,CAAA;IAChC,IAAI,O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babel/core';\nimport solid from 'babel-preset-solid';\nimport { readFileSync } from 'fs';\nimport { mergeAndConcat } from 'merge-anything';\nimport { createRequire } from 'module';\nimport solidRefresh from 'solid-refresh/babel';\nimport { createFilter } from 'vite';\nimport type { Alias, AliasOptions, Plugin, FilterPattern } from 'vite';\nimport { crawlFrameworkPkgs } from 'vitefu';\n\nconst require = createRequire(import.meta.url);\n\nconst runtimePublicPath = '/@solid-refresh';\nconst runtimeFilePath = require.resolve('solid-refresh/dist/solid-refresh.mjs');\nconst runtimeCode = readFileSync(runtimeFilePath, 'utf-8');\n\n/** Possible options for the extensions property */\nexport interface ExtensionOptions {\n typescript?: boolean;\n}\n\n/** Configuration options for vite-plugin-solid. */\nexport interface Options {\n /**\n * A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files\n * the plugin should operate on.\n */\n include?: FilterPattern;\n /**\n * A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files\n * to be ignored by the plugin.\n */\n exclude?: FilterPattern;\n /**\n * This will inject solid-js/dev in place of solid-js in dev mode. Has no\n * effect in prod. If set to `false`, it won't inject it in dev. This is\n * useful for extra logs and debugging.\n *\n * @default true\n */\n dev: boolean;\n /**\n * This will force SSR code in the produced files. This is experiemental\n * and mostly not working yet.\n *\n * @default false\n */\n ssr: boolean;\n\n /**\n * This will inject HMR runtime in dev mode. Has no effect in prod. If\n * set to `false`, it won't inject the runtime in dev.\n *\n * @default true\n */\n hot: boolean;\n /**\n * This registers additional extensions that should be processed by\n * vite-plugin-solid.\n *\n * @default undefined\n */\n extensions?: (string | [string, ExtensionOptions])[];\n /**\n * Pass any additional babel transform options. They will be merged with\n * the transformations required by Solid.\n *\n * @default {}\n */\n babel:\n | babel.TransformOptions\n | ((source: string, id: string, ssr: boolean) => babel.TransformOptions)\n | ((source: string, id: string, ssr: boolean) => Promise<babel.TransformOptions>);\n /**\n * Pass any additional [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/tree/main/packages/babel-plugin-jsx-dom-expressions#plugin-options).\n * They will be merged with the defaults sets by [babel-preset-solid](https://github.com/solidjs/solid/blob/main/packages/babel-preset-solid/index.js#L8-L25).\n *\n * @default {}\n */\n solid: {\n /**\n * Removed unnecessary closing tags from template strings. More info here:\n * https://github.com/solidjs/solid/blob/main/CHANGELOG.md#smaller-templates\n *\n * @default false\n */\n omitNestedClosingTags: boolean;\n\n /**\n * The name of the runtime module to import the methods from.\n *\n * @default \"solid-js/web\"\n */\n moduleName?: string;\n\n /**\n * The output mode of the compiler.\n * Can be:\n * - \"dom\" is standard output\n * - \"ssr\" is for server side rendering of strings.\n * - \"universal\" is for using custom renderers from solid-js/universal\n *\n * @default \"dom\"\n */\n generate?: 'ssr' | 'dom' | 'universal';\n\n /**\n * Indicate whether the output should contain hydratable markers.\n *\n * @default false\n */\n hydratable?: boolean;\n\n /**\n * Boolean to indicate whether to enable automatic event delegation on camelCase.\n *\n * @default true\n */\n delegateEvents?: boolean;\n\n /**\n * Boolean indicates whether smart conditional detection should be used.\n * This optimizes simple boolean expressions and ternaries in JSX.\n *\n * @default true\n */\n wrapConditionals?: boolean;\n\n /**\n * Boolean indicates whether to set current render context on Custom Elements and slots.\n * Useful for seemless Context API with Web Components.\n *\n * @default true\n */\n contextToCustomElements?: boolean;\n\n /**\n * Array of Component exports from module, that aren't included by default with the library.\n * This plugin will automatically import them if it comes across them in the JSX.\n *\n * @default [\"For\",\"Show\",\"Switch\",\"Match\",\"Suspense\",\"SuspenseList\",\"Portal\",\"Index\",\"Dynamic\",\"ErrorBoundary\"]\n */\n builtIns?: string[];\n };\n}\n\nfunction getExtension(filename: string): string {\n const index = filename.lastIndexOf('.');\n return index < 0 ? '' : filename.substring(index).replace(/\\?.+$/, '');\n}\nfunction containsSolidField(fields: Record<string, any>) {\n const keys = Object.keys(fields);\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n if (key === 'solid') return true;\n if (typeof fields[key] === 'object' && fields[key] != null && containsSolidField(fields[key]))\n return true;\n }\n return false;\n}\n\nfunction getJestDomExport(setupFiles: string[]) {\n return setupFiles?.some((path) => /jest-dom/.test(path))\n ? undefined\n : ['@testing-library/jest-dom/vitest', '@testing-library/jest-dom/extend-expect'].find(\n (path) => {\n try {\n require.resolve(path);\n return true;\n } catch (e) {\n return false;\n }\n },\n );\n}\n\nexport default function solidPlugin(options: Partial<Options> = {}): Plugin {\n const filter = createFilter(options.include, options.exclude);\n\n let needHmr = false;\n let replaceDev = false;\n let projectRoot = process.cwd();\n\n return {\n name: 'solid',\n enforce: 'pre',\n\n async config(userConfig, { command }) {\n // We inject the dev mode only if the user explicitely wants it or if we are in dev (serve) mode\n replaceDev = options.dev === true || (options.dev !== false && command === 'serve');\n projectRoot = userConfig.root;\n\n if (!userConfig.resolve) userConfig.resolve = {};\n userConfig.resolve.alias = normalizeAliases(userConfig.resolve && userConfig.resolve.alias);\n\n const solidPkgsConfig = await crawlFrameworkPkgs({\n viteUserConfig: userConfig,\n root: projectRoot || process.cwd(),\n isBuild: command === 'build',\n isFrameworkPkgByJson(pkgJson) {\n return containsSolidField(pkgJson.exports || {});\n },\n });\n\n // fix for bundling dev in production\n const nestedDeps = replaceDev\n ? ['solid-js', 'solid-js/web', 'solid-js/store', 'solid-js/html', 'solid-js/h']\n : [];\n\n const test = (userConfig as any).test || {};\n\n if (userConfig.mode === 'test') {\n // to simplify the processing of the config, we normalize the setupFiles to an array\n const userSetupFiles: string[] =\n typeof test.setupFiles === 'string' ? [test.setupFiles] : test.setupFiles || [];\n\n if (!test.environment && !options.ssr) {\n test.environment = 'jsdom';\n }\n\n test.server = test.server || {};\n test.server.deps = test.server.deps || {};\n if (!test.server.deps.inline?.find((item: string | RegExp) => /solid-js/.test(item.toString()))) {\n test.server.deps.inline = [...(test.server.deps.inline || []), /solid-js/];\n }\n\n const jestDomImport = getJestDomExport(userSetupFiles);\n if (jestDomImport) {\n test.setupFiles = [...userSetupFiles, jestDomImport];\n }\n }\n\n return {\n /**\n * We only need esbuild on .ts or .js files.\n * .tsx & .jsx files are handled by us\n */\n // esbuild: { include: /\\.ts$/ },\n resolve: {\n conditions: [\n 'solid',\n ...(replaceDev ? ['development'] : []),\n ...(userConfig.mode === 'test' && !options.ssr ? ['browser'] : []),\n ],\n dedupe: nestedDeps,\n alias: [{ find: /^solid-refresh$/, replacement: runtimePublicPath }],\n },\n optimizeDeps: {\n include: [...nestedDeps, ...solidPkgsConfig.optimizeDeps.include],\n exclude: solidPkgsConfig.optimizeDeps.exclude,\n },\n ssr: solidPkgsConfig.ssr,\n ...(test.server ? { test } : {}),\n };\n },\n\n configResolved(config) {\n needHmr = config.command === 'serve' && config.mode !== 'production' && options.hot !== false;\n },\n\n resolveId(id) {\n if (id === runtimePublicPath) return id;\n },\n\n load(id) {\n if (id === runtimePublicPath) return runtimeCode;\n },\n\n async transform(source, id, transformOptions) {\n const isSsr = transformOptions && transformOptions.ssr;\n const currentFileExtension = getExtension(id);\n\n const extensionsToWatch = options.extensions || [];\n const allExtensions = extensionsToWatch.map((extension) =>\n // An extension can be a string or a tuple [extension, options]\n typeof extension === 'string' ? extension : extension[0],\n );\n\n if (!filter(id) || !(/\\.[mc]?[tj]sx$/i.test(id) || allExtensions.includes(currentFileExtension))) {\n return null;\n }\n\n const inNodeModules = /node_modules/.test(id);\n\n let solidOptions: { generate: 'ssr' | 'dom'; hydratable: boolean };\n\n if (options.ssr) {\n if (isSsr) {\n solidOptions = { generate: 'ssr', hydratable: true };\n } else {\n solidOptions = { generate: 'dom', hydratable: true };\n }\n } else {\n solidOptions = { generate: 'dom', hydratable: false };\n }\n\n id = id.replace(/\\?.+$/, '');\n\n // We need to know if the current file extension has a typescript options tied to it\n const shouldBeProcessedWithTypescript = /\\.[mc]?tsx$/i.test(id) || extensionsToWatch.some((extension) => {\n if (typeof extension === 'string') {\n return extension.includes('tsx');\n }\n\n const [extensionName, extensionOptions] = extension;\n if (extensionName !== currentFileExtension) return false;\n\n return extensionOptions.typescript;\n });\n const plugins: NonNullable<NonNullable<babel.TransformOptions['parserOpts']>['plugins']> = ['jsx']\n\n if (shouldBeProcessedWithTypescript) {\n plugins.push('typescript');\n }\n\n const opts: babel.TransformOptions = {\n root: projectRoot,\n filename: id,\n sourceFileName: id,\n presets: [[solid, { ...solidOptions, ...(options.solid || {}) }]],\n plugins: needHmr && !isSsr && !inNodeModules ? [[solidRefresh, { bundler: 'vite' }]] : [],\n ast: false,\n sourceMaps: true,\n configFile: false,\n babelrc: false,\n parserOpts: {\n plugins,\n },\n };\n\n // Default value for babel user options\n let babelUserOptions: babel.TransformOptions = {};\n\n if (options.babel) {\n if (typeof options.babel === 'function') {\n const babelOptions = options.babel(source, id, isSsr);\n babelUserOptions = babelOptions instanceof Promise ? await babelOptions : babelOptions;\n } else {\n babelUserOptions = options.babel;\n }\n }\n\n const babelOptions = mergeAndConcat(babelUserOptions, opts) as babel.TransformOptions;\n\n const { code, map } = await babel.transformAsync(source, babelOptions);\n\n return { code, map };\n },\n };\n}\n\n/**\n * This basically normalize all aliases of the config into\n * the array format of the alias.\n *\n * eg: alias: { '@': 'src/' } => [{ find: '@', replacement: 'src/' }]\n */\nfunction normalizeAliases(alias: AliasOptions = []): Alias[] {\n return Array.isArray(alias)\n ? alias\n : Object.entries(alias).map(([find, replacement]) => ({ find, replacement }));\n}\n"],"names":["require","createRequire","import","runtimePublicPath","runtimeFilePath","resolve","runtimeCode","readFileSync","getExtension","filename","index","lastIndexOf","substring","replace","containsSolidField","fields","keys","Object","i","length","key","getJestDomExport","setupFiles","some","path","test","undefined","find","e","solidPlugin","options","filter","createFilter","include","exclude","needHmr","replaceDev","projectRoot","process","cwd","name","enforce","config","userConfig","command","dev","root","alias","normalizeAliases","solidPkgsConfig","crawlFrameworkPkgs","viteUserConfig","isBuild","isFrameworkPkgByJson","pkgJson","exports","nestedDeps","mode","userSetupFiles","environment","ssr","server","deps","inline","item","toString","jestDomImport","conditions","dedupe","replacement","optimizeDeps","configResolved","hot","resolveId","id","load","transform","source","transformOptions","isSsr","currentFileExtension","extensionsToWatch","extensions","allExtensions","map","extension","includes","inNodeModules","solidOptions","generate","hydratable","shouldBeProcessedWithTypescript","extensionName","extensionOptions","typescript","plugins","push","opts","sourceFileName","presets","solid","solidRefresh","bundler","ast","sourceMaps","configFile","babelrc","parserOpts","babelUserOptions","babel","babelOptions","Promise","mergeAndConcat","code","transformAsync","Array","isArray","entries"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAMA,SAAO,GAAGC,sBAAa,CAACC,8LAAe,CAAC,CAAA;AAE9C,MAAMC,iBAAiB,GAAG,iBAAiB,CAAA;AAC3C,MAAMC,eAAe,GAAGJ,SAAO,CAACK,OAAO,CAAC,sCAAsC,CAAC,CAAA;AAC/E,MAAMC,WAAW,GAAGC,eAAY,CAACH,eAAe,EAAE,OAAO,CAAC,CAAA;;AAE1D;;AAKA;;AA6HA,SAASI,YAAYA,CAACC,QAAgB,EAAU;AAC9C,EAAA,MAAMC,KAAK,GAAGD,QAAQ,CAACE,WAAW,CAAC,GAAG,CAAC,CAAA;AACvC,EAAA,OAAOD,KAAK,GAAG,CAAC,GAAG,EAAE,GAAGD,QAAQ,CAACG,SAAS,CAACF,KAAK,CAAC,CAACG,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAA;AACxE,CAAA;AACA,SAASC,kBAAkBA,CAACC,MAA2B,EAAE;AACvD,EAAA,MAAMC,IAAI,GAAGC,MAAM,CAACD,IAAI,CAACD,MAAM,CAAC,CAAA;AAChC,EAAA,KAAK,IAAIG,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,IAAI,CAACG,MAAM,EAAED,CAAC,EAAE,EAAE;AACpC,IAAA,MAAME,GAAG,GAAGJ,IAAI,CAACE,CAAC,CAAC,CAAA;AACnB,IAAA,IAAIE,GAAG,KAAK,OAAO,EAAE,OAAO,IAAI,CAAA;IAChC,IAAI,OAAOL,MAAM,CAACK,GAAG,CAAC,KAAK,QAAQ,IAAIL,MAA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AAEG,IAAI;AAAE7B,QAAAA,GAAAA;OAAK,CAAA;AACtB,KAAA;GACD,CAAA;AACH,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASpC,gBAAgBA,CAACD,KAAmB,GAAG,EAAE,EAAW;EAC3D,OAAOoE,KAAK,CAACC,OAAO,CAACrE,KAAK,CAAC,GACvBA,KAAK,GACL9B,MAAM,CAACoG,OAAO,CAACtE,KAAK,CAAC,CAACqC,GAAG,CAAC,CAAC,CAACzD,IAAI,EAAE0C,WAAW,CAAC,MAAM;IAAE1C,IAAI;AAAE0C,IAAAA,WAAAA;AAAY,GAAC,CAAC,CAAC,CAAA;AACjF;;;;"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import ts from '@babel/preset-typescript';
|
|
1
|
+
import * as babel from '@babel/core';
|
|
3
2
|
import solid from 'babel-preset-solid';
|
|
4
3
|
import { readFileSync } from 'fs';
|
|
5
4
|
import { mergeAndConcat } from 'merge-anything';
|
|
@@ -31,9 +30,10 @@ function containsSolidField(fields) {
|
|
|
31
30
|
return false;
|
|
32
31
|
}
|
|
33
32
|
function getJestDomExport(setupFiles) {
|
|
34
|
-
return
|
|
33
|
+
return setupFiles?.some(path => /jest-dom/.test(path)) ? undefined : ['@testing-library/jest-dom/vitest', '@testing-library/jest-dom/extend-expect'].find(path => {
|
|
35
34
|
try {
|
|
36
|
-
require(path);
|
|
35
|
+
require.resolve(path);
|
|
36
|
+
return true;
|
|
37
37
|
} catch (e) {
|
|
38
38
|
return false;
|
|
39
39
|
}
|
|
@@ -67,16 +67,20 @@ function solidPlugin(options = {}) {
|
|
|
67
67
|
// fix for bundling dev in production
|
|
68
68
|
const nestedDeps = replaceDev ? ['solid-js', 'solid-js/web', 'solid-js/store', 'solid-js/html', 'solid-js/h'] : [];
|
|
69
69
|
const test = userConfig.test || {};
|
|
70
|
-
|
|
71
|
-
// to simplify the processing of the config, we normalize the setupFiles to an array
|
|
72
|
-
const userSetupFiles = typeof test.setupFiles === 'string' ? [test.setupFiles] : test.setupFiles || [];
|
|
73
70
|
if (userConfig.mode === 'test') {
|
|
71
|
+
// to simplify the processing of the config, we normalize the setupFiles to an array
|
|
72
|
+
const userSetupFiles = typeof test.setupFiles === 'string' ? [test.setupFiles] : test.setupFiles || [];
|
|
74
73
|
if (!test.environment && !options.ssr) {
|
|
75
74
|
test.environment = 'jsdom';
|
|
76
75
|
}
|
|
76
|
+
test.server = test.server || {};
|
|
77
|
+
test.server.deps = test.server.deps || {};
|
|
78
|
+
if (!test.server.deps.inline?.find(item => /solid-js/.test(item.toString()))) {
|
|
79
|
+
test.server.deps.inline = [...(test.server.deps.inline || []), /solid-js/];
|
|
80
|
+
}
|
|
77
81
|
const jestDomImport = getJestDomExport(userSetupFiles);
|
|
78
82
|
if (jestDomImport) {
|
|
79
|
-
test.setupFiles = [...userSetupFiles,
|
|
83
|
+
test.setupFiles = [...userSetupFiles, jestDomImport];
|
|
80
84
|
}
|
|
81
85
|
}
|
|
82
86
|
return {
|
|
@@ -84,9 +88,7 @@ function solidPlugin(options = {}) {
|
|
|
84
88
|
* We only need esbuild on .ts or .js files.
|
|
85
89
|
* .tsx & .jsx files are handled by us
|
|
86
90
|
*/
|
|
87
|
-
esbuild: {
|
|
88
|
-
include: /\.ts$/
|
|
89
|
-
},
|
|
91
|
+
// esbuild: { include: /\.ts$/ },
|
|
90
92
|
resolve: {
|
|
91
93
|
conditions: ['solid', ...(replaceDev ? ['development'] : []), ...(userConfig.mode === 'test' && !options.ssr ? ['browser'] : [])],
|
|
92
94
|
dedupe: nestedDeps,
|
|
@@ -100,7 +102,7 @@ function solidPlugin(options = {}) {
|
|
|
100
102
|
exclude: solidPkgsConfig.optimizeDeps.exclude
|
|
101
103
|
},
|
|
102
104
|
ssr: solidPkgsConfig.ssr,
|
|
103
|
-
...(test ? {
|
|
105
|
+
...(test.server ? {
|
|
104
106
|
test
|
|
105
107
|
} : {})
|
|
106
108
|
};
|
|
@@ -117,11 +119,11 @@ function solidPlugin(options = {}) {
|
|
|
117
119
|
async transform(source, id, transformOptions) {
|
|
118
120
|
const isSsr = transformOptions && transformOptions.ssr;
|
|
119
121
|
const currentFileExtension = getExtension(id);
|
|
120
|
-
const extensionsToWatch =
|
|
122
|
+
const extensionsToWatch = options.extensions || [];
|
|
121
123
|
const allExtensions = extensionsToWatch.map(extension =>
|
|
122
124
|
// An extension can be a string or a tuple [extension, options]
|
|
123
125
|
typeof extension === 'string' ? extension : extension[0]);
|
|
124
|
-
if (!filter(id) || !allExtensions.includes(currentFileExtension)) {
|
|
126
|
+
if (!filter(id) || !(/\.[mc]?[tj]sx$/i.test(id) || allExtensions.includes(currentFileExtension))) {
|
|
125
127
|
return null;
|
|
126
128
|
}
|
|
127
129
|
const inNodeModules = /node_modules/.test(id);
|
|
@@ -145,9 +147,21 @@ function solidPlugin(options = {}) {
|
|
|
145
147
|
};
|
|
146
148
|
}
|
|
147
149
|
id = id.replace(/\?.+$/, '');
|
|
150
|
+
|
|
151
|
+
// We need to know if the current file extension has a typescript options tied to it
|
|
152
|
+
const shouldBeProcessedWithTypescript = /\.[mc]?tsx$/i.test(id) || extensionsToWatch.some(extension => {
|
|
153
|
+
if (typeof extension === 'string') {
|
|
154
|
+
return extension.includes('tsx');
|
|
155
|
+
}
|
|
156
|
+
const [extensionName, extensionOptions] = extension;
|
|
157
|
+
if (extensionName !== currentFileExtension) return false;
|
|
158
|
+
return extensionOptions.typescript;
|
|
159
|
+
});
|
|
160
|
+
const plugins = ['jsx'];
|
|
161
|
+
if (shouldBeProcessedWithTypescript) {
|
|
162
|
+
plugins.push('typescript');
|
|
163
|
+
}
|
|
148
164
|
const opts = {
|
|
149
|
-
babelrc: false,
|
|
150
|
-
configFile: false,
|
|
151
165
|
root: projectRoot,
|
|
152
166
|
filename: id,
|
|
153
167
|
sourceFileName: id,
|
|
@@ -158,23 +172,14 @@ function solidPlugin(options = {}) {
|
|
|
158
172
|
plugins: needHmr && !isSsr && !inNodeModules ? [[solidRefresh, {
|
|
159
173
|
bundler: 'vite'
|
|
160
174
|
}]] : [],
|
|
175
|
+
ast: false,
|
|
161
176
|
sourceMaps: true,
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
// We need to know if the current file extension has a typescript options tied to it
|
|
167
|
-
const shouldBeProcessedWithTypescript = extensionsToWatch.some(extension => {
|
|
168
|
-
if (typeof extension === 'string') {
|
|
169
|
-
return extension.includes('tsx');
|
|
177
|
+
configFile: false,
|
|
178
|
+
babelrc: false,
|
|
179
|
+
parserOpts: {
|
|
180
|
+
plugins
|
|
170
181
|
}
|
|
171
|
-
|
|
172
|
-
if (extensionName !== currentFileExtension) return false;
|
|
173
|
-
return extensionOptions.typescript;
|
|
174
|
-
});
|
|
175
|
-
if (shouldBeProcessedWithTypescript) {
|
|
176
|
-
opts.presets.push([ts, options.typescript || {}]);
|
|
177
|
-
}
|
|
182
|
+
};
|
|
178
183
|
|
|
179
184
|
// Default value for babel user options
|
|
180
185
|
let babelUserOptions = {};
|
|
@@ -190,7 +195,7 @@ function solidPlugin(options = {}) {
|
|
|
190
195
|
const {
|
|
191
196
|
code,
|
|
192
197
|
map
|
|
193
|
-
} = await transformAsync(source, babelOptions);
|
|
198
|
+
} = await babel.transformAsync(source, babelOptions);
|
|
194
199
|
return {
|
|
195
200
|
code,
|
|
196
201
|
map
|
package/dist/esm/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":["../../src/index.ts"],"sourcesContent":["import { transformAsync, TransformOptions } from '@babel/core';\nimport ts from '@babel/preset-typescript';\nimport solid from 'babel-preset-solid';\nimport { readFileSync } from 'fs';\nimport { mergeAndConcat } from 'merge-anything';\nimport { createRequire } from 'module';\nimport solidRefresh from 'solid-refresh/babel';\nimport { createFilter } from 'vite';\nimport type { Alias, AliasOptions, Plugin, FilterPattern } from 'vite';\nimport { crawlFrameworkPkgs } from 'vitefu';\n\nconst require = createRequire(import.meta.url);\n\nconst runtimePublicPath = '/@solid-refresh';\nconst runtimeFilePath = require.resolve('solid-refresh/dist/solid-refresh.mjs');\nconst runtimeCode = readFileSync(runtimeFilePath, 'utf-8');\n\n/** Possible options for the extensions property */\nexport interface ExtensionOptions {\n typescript?: boolean;\n}\n\n/** Configuration options for vite-plugin-solid. */\nexport interface Options {\n /**\n * A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files\n * the plugin should operate on.\n */\n include?: FilterPattern;\n /**\n * A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files\n * to be ignored by the plugin.\n */\n exclude?: FilterPattern;\n /**\n * This will inject solid-js/dev in place of solid-js in dev mode. Has no\n * effect in prod. If set to `false`, it won't inject it in dev. This is\n * useful for extra logs and debugging.\n *\n * @default true\n */\n dev: boolean;\n /**\n * This will force SSR code in the produced files. This is experiemental\n * and mostly not working yet.\n *\n * @default false\n */\n ssr: boolean;\n\n /**\n * This will inject HMR runtime in dev mode. Has no effect in prod. If\n * set to `false`, it won't inject the runtime in dev.\n *\n * @default true\n */\n hot: boolean;\n /**\n * This registers additional extensions that should be processed by\n * vite-plugin-solid.\n *\n * @default undefined\n */\n extensions?: (string | [string, ExtensionOptions])[];\n /**\n * Pass any additional babel transform options. They will be merged with\n * the transformations required by Solid.\n *\n * @default {}\n */\n babel:\n | TransformOptions\n | ((source: string, id: string, ssr: boolean) => TransformOptions)\n | ((source: string, id: string, ssr: boolean) => Promise<TransformOptions>);\n typescript: {\n /**\n * Forcibly enables jsx parsing. Otherwise angle brackets will be treated as\n * typescript's legacy type assertion var foo = <string>bar;. Also, isTSX:\n * true requires allExtensions: true.\n *\n * @default false\n */\n isTSX?: boolean;\n\n /**\n * Replace the function used when compiling JSX expressions. This is so that\n * we know that the import is not a type import, and should not be removed.\n *\n * @default React\n */\n jsxPragma?: string;\n\n /**\n * Replace the function used when compiling JSX fragment expressions. This\n * is so that we know that the import is not a type import, and should not\n * be removed.\n *\n * @default React.Fragment\n */\n jsxPragmaFrag?: string;\n\n /**\n * Indicates that every file should be parsed as TS or TSX (depending on the\n * isTSX option).\n *\n * @default false\n */\n allExtensions?: boolean;\n\n /**\n * Enables compilation of TypeScript namespaces.\n *\n * @default uses the default set by @babel/plugin-transform-typescript.\n */\n allowNamespaces?: boolean;\n\n /**\n * When enabled, type-only class fields are only removed if they are\n * prefixed with the declare modifier:\n *\n * > NOTE: This will be enabled by default in Babel 8\n *\n * @default false\n *\n * @example\n * ```ts\n * class A {\n * declare foo: string; // Removed\n * bar: string; // Initialized to undefined\n * prop?: string; // Initialized to undefined\n * prop1!: string // Initialized to undefined\n * }\n * ```\n */\n allowDeclareFields?: boolean;\n\n /**\n * When set to true, the transform will only remove type-only imports\n * (introduced in TypeScript 3.8). This should only be used if you are using\n * TypeScript >= 3.8.\n *\n * @default false\n */\n onlyRemoveTypeImports?: boolean;\n\n /**\n * When set to true, Babel will inline enum values rather than using the\n * usual enum output:\n *\n * This option differs from TypeScript's --isolatedModules behavior, which\n * ignores the const modifier and compiles them as normal enums, and aligns\n * Babel's behavior with TypeScript's default behavior.\n *\n * ```ts\n * // Input\n * const enum Animals {\n * Fish\n * }\n * console.log(Animals.Fish);\n *\n * // Default output\n * var Animals;\n *\n * (function (Animals) {\n * Animals[Animals[\"Fish\"] = 0] = \"Fish\";\n * })(Animals || (Animals = {}));\n *\n * console.log(Animals.Fish);\n *\n * // `optimizeConstEnums` output\n * console.log(0);\n * ```\n *\n * However, when exporting a const enum Babel will compile it to a plain\n * object literal so that it doesn't need to rely on cross-file analysis\n * when compiling it:\n *\n * ```ts\n * // Input\n * export const enum Animals {\n * Fish,\n * }\n *\n * // `optimizeConstEnums` output\n * export var Animals = {\n * Fish: 0,\n * };\n * ```\n *\n * @default false\n */\n optimizeConstEnums?: boolean;\n };\n /**\n * Pass any additional [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/tree/main/packages/babel-plugin-jsx-dom-expressions#plugin-options).\n * They will be merged with the defaults sets by [babel-preset-solid](https://github.com/solidjs/solid/blob/main/packages/babel-preset-solid/index.js#L8-L25).\n *\n * @default {}\n */\n solid: {\n /**\n * Removed unnecessary closing tags from template strings. More info here:\n * https://github.com/solidjs/solid/blob/main/CHANGELOG.md#smaller-templates\n *\n * @default false\n */\n omitNestedClosingTags: boolean;\n\n /**\n * The name of the runtime module to import the methods from.\n *\n * @default \"solid-js/web\"\n */\n moduleName?: string;\n\n /**\n * The output mode of the compiler.\n * Can be:\n * - \"dom\" is standard output\n * - \"ssr\" is for server side rendering of strings.\n * - \"universal\" is for using custom renderers from solid-js/universal\n *\n * @default \"dom\"\n */\n generate?: 'ssr' | 'dom' | 'universal';\n\n /**\n * Indicate whether the output should contain hydratable markers.\n *\n * @default false\n */\n hydratable?: boolean;\n\n /**\n * Boolean to indicate whether to enable automatic event delegation on camelCase.\n *\n * @default true\n */\n delegateEvents?: boolean;\n\n /**\n * Boolean indicates whether smart conditional detection should be used.\n * This optimizes simple boolean expressions and ternaries in JSX.\n *\n * @default true\n */\n wrapConditionals?: boolean;\n\n /**\n * Boolean indicates whether to set current render context on Custom Elements and slots.\n * Useful for seemless Context API with Web Components.\n *\n * @default true\n */\n contextToCustomElements?: boolean;\n\n /**\n * Array of Component exports from module, that aren't included by default with the library.\n * This plugin will automatically import them if it comes across them in the JSX.\n *\n * @default [\"For\",\"Show\",\"Switch\",\"Match\",\"Suspense\",\"SuspenseList\",\"Portal\",\"Index\",\"Dynamic\",\"ErrorBoundary\"]\n */\n builtIns?: string[];\n };\n}\n\nfunction getExtension(filename: string): string {\n const index = filename.lastIndexOf('.');\n return index < 0 ? '' : filename.substring(index).replace(/\\?.+$/, '');\n}\nfunction containsSolidField(fields: Record<string, any>) {\n const keys = Object.keys(fields);\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n if (key === 'solid') return true;\n if (typeof fields[key] === 'object' && fields[key] != null && containsSolidField(fields[key]))\n return true;\n }\n return false;\n}\n\nfunction getJestDomExport(setupFiles: string[]) {\n return (setupFiles || []).some((path) => /jest-dom/.test(path))\n ? undefined\n : ['@testing-library/jest-dom/vitest', '@testing-library/jest-dom/extend-expect'].find(\n (path) => {\n try {\n require(path);\n } catch (e) {\n return false;\n }\n },\n );\n}\n\nexport default function solidPlugin(options: Partial<Options> = {}): Plugin {\n const filter = createFilter(options.include, options.exclude);\n\n let needHmr = false;\n let replaceDev = false;\n let projectRoot = process.cwd();\n\n return {\n name: 'solid',\n enforce: 'pre',\n\n async config(userConfig, { command }) {\n // We inject the dev mode only if the user explicitely wants it or if we are in dev (serve) mode\n replaceDev = options.dev === true || (options.dev !== false && command === 'serve');\n projectRoot = userConfig.root;\n\n if (!userConfig.resolve) userConfig.resolve = {};\n userConfig.resolve.alias = normalizeAliases(userConfig.resolve && userConfig.resolve.alias);\n\n const solidPkgsConfig = await crawlFrameworkPkgs({\n viteUserConfig: userConfig,\n root: projectRoot || process.cwd(),\n isBuild: command === 'build',\n isFrameworkPkgByJson(pkgJson) {\n return containsSolidField(pkgJson.exports || {});\n },\n });\n\n // fix for bundling dev in production\n const nestedDeps = replaceDev\n ? ['solid-js', 'solid-js/web', 'solid-js/store', 'solid-js/html', 'solid-js/h']\n : [];\n\n const test = (userConfig as any).test || {};\n\n // to simplify the processing of the config, we normalize the setupFiles to an array\n const userSetupFiles: string[] =\n typeof test.setupFiles === 'string' ? [test.setupFiles] : test.setupFiles || [];\n\n if (userConfig.mode === 'test') {\n if (!test.environment && !options.ssr) {\n test.environment = 'jsdom';\n }\n\n const jestDomImport = getJestDomExport(userSetupFiles);\n\n if (jestDomImport) {\n test.setupFiles = [...userSetupFiles, require.resolve(jestDomImport)];\n }\n }\n\n return {\n /**\n * We only need esbuild on .ts or .js files.\n * .tsx & .jsx files are handled by us\n */\n esbuild: { include: /\\.ts$/ },\n resolve: {\n conditions: [\n 'solid',\n ...(replaceDev ? ['development'] : []),\n ...(userConfig.mode === 'test' && !options.ssr ? ['browser'] : []),\n ],\n dedupe: nestedDeps,\n alias: [{ find: /^solid-refresh$/, replacement: runtimePublicPath }],\n },\n optimizeDeps: {\n include: [...nestedDeps, ...solidPkgsConfig.optimizeDeps.include],\n exclude: solidPkgsConfig.optimizeDeps.exclude,\n },\n ssr: solidPkgsConfig.ssr,\n ...(test ? { test } : {}),\n };\n },\n\n configResolved(config) {\n needHmr = config.command === 'serve' && config.mode !== 'production' && options.hot !== false;\n },\n\n resolveId(id) {\n if (id === runtimePublicPath) return id;\n },\n\n load(id) {\n if (id === runtimePublicPath) return runtimeCode;\n },\n\n async transform(source, id, transformOptions) {\n const isSsr = transformOptions && transformOptions.ssr;\n const currentFileExtension = getExtension(id);\n\n const extensionsToWatch = [...(options.extensions || []), '.tsx', '.jsx'];\n const allExtensions = extensionsToWatch.map((extension) =>\n // An extension can be a string or a tuple [extension, options]\n typeof extension === 'string' ? extension : extension[0],\n );\n\n if (!filter(id) || !allExtensions.includes(currentFileExtension)) {\n return null;\n }\n\n const inNodeModules = /node_modules/.test(id);\n\n let solidOptions: { generate: 'ssr' | 'dom'; hydratable: boolean };\n\n if (options.ssr) {\n if (isSsr) {\n solidOptions = { generate: 'ssr', hydratable: true };\n } else {\n solidOptions = { generate: 'dom', hydratable: true };\n }\n } else {\n solidOptions = { generate: 'dom', hydratable: false };\n }\n\n id = id.replace(/\\?.+$/, '');\n\n const opts: TransformOptions = {\n babelrc: false,\n configFile: false,\n root: projectRoot,\n filename: id,\n sourceFileName: id,\n presets: [[solid, { ...solidOptions, ...(options.solid || {}) }]],\n plugins: needHmr && !isSsr && !inNodeModules ? [[solidRefresh, { bundler: 'vite' }]] : [],\n sourceMaps: true,\n // Vite handles sourcemap flattening\n inputSourceMap: false as any,\n };\n\n // We need to know if the current file extension has a typescript options tied to it\n const shouldBeProcessedWithTypescript = extensionsToWatch.some((extension) => {\n if (typeof extension === 'string') {\n return extension.includes('tsx');\n }\n\n const [extensionName, extensionOptions] = extension;\n if (extensionName !== currentFileExtension) return false;\n\n return extensionOptions.typescript;\n });\n\n if (shouldBeProcessedWithTypescript) {\n opts.presets.push([ts, options.typescript || {}]);\n }\n\n // Default value for babel user options\n let babelUserOptions: TransformOptions = {};\n\n if (options.babel) {\n if (typeof options.babel === 'function') {\n const babelOptions = options.babel(source, id, isSsr);\n babelUserOptions = babelOptions instanceof Promise ? await babelOptions : babelOptions;\n } else {\n babelUserOptions = options.babel;\n }\n }\n\n const babelOptions = mergeAndConcat(babelUserOptions, opts) as TransformOptions;\n\n const { code, map } = await transformAsync(source, babelOptions);\n\n return { code, map };\n },\n };\n}\n\n/**\n * This basically normalize all aliases of the config into\n * the array format of the alias.\n *\n * eg: alias: { '@': 'src/' } => [{ find: '@', replacement: 'src/' }]\n */\nfunction normalizeAliases(alias: AliasOptions = []): Alias[] {\n return Array.isArray(alias)\n ? alias\n : Object.entries(alias).map(([find, replacement]) => ({ find, replacement }));\n}\n"],"names":["require","createRequire","import","meta","url","runtimePublicPath","runtimeFilePath","resolve","runtimeCode","readFileSync","getExtension","filename","index","lastIndexOf","substring","replace","containsSolidField","fields","keys","Object","i","length","key","getJestDomExport","setupFiles","some","path","test","undefined","find","e","solidPlugin","options","filter","createFilter","include","exclude","needHmr","replaceDev","projectRoot","process","cwd","name","enforce","config","userConfig","command","dev","root","alias","normalizeAliases","solidPkgsConfig","crawlFrameworkPkgs","viteUserConfig","isBuild","isFrameworkPkgByJson","pkgJson","exports","nestedDeps","userSetupFiles","mode","environment","ssr","jestDomImport","esbuild","conditions","dedupe","replacement","optimizeDeps","configResolved","hot","resolveId","id","load","transform","source","transformOptions","isSsr","currentFileExtension","extensionsToWatch","extensions","allExtensions","map","extension","includes","inNodeModules","solidOptions","generate","hydratable","opts","babelrc","configFile","sourceFileName","presets","solid","plugins","solidRefresh","bundler","sourceMaps","inputSourceMap","shouldBeProcessedWithTypescript","extensionName","extensionOptions","typescript","push","ts","babelUserOptions","babel","babelOptions","Promise","mergeAndConcat","code","transformAsync","Array","isArray","entries"],"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AAM,EAAEH,EAAE,EAAEK,KAAK,CAAC,CAAA;UACrD6B,gBAAgB,GAAGE,YAAY,YAAYC,OAAO,GAAG,MAAMD,YAAY,GAAGA,YAAY,CAAA;AACxF,SAAC,MAAM;UACLF,gBAAgB,GAAG1E,OAAO,CAAC2E,KAAK,CAAA;AAClC,SAAA;AACF,OAAA;AAEA,MAAA,MAAMC,YAAY,GAAGE,cAAc,CAACJ,gBAAgB,EAAEjB,IAAI,CAAqB,CAAA;MAE/E,MAAM;QAAEsB,IAAI;AAAE7B,QAAAA,GAAAA;AAAI,OAAC,GAAG,MAAM8B,cAAc,CAACrC,MAAM,EAAEiC,YAAY,CAAC,CAAA;MAEhE,OAAO;QAAEG,IAAI;AAAE7B,QAAAA,GAAAA;OAAK,CAAA;AACtB,KAAA;GACD,CAAA;AACH,CAAA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAAShC,gBAAgBA,CAACD,KAAmB,GAAG,EAAE,EAAW;EAC3D,OAAOgE,KAAK,CAACC,OAAO,CAACjE,KAAK,CAAC,GACvBA,KAAK,GACL9B,MAAM,CAACgG,OAAO,CAAClE,KAAK,CAAC,CAACiC,GAAG,CAAC,CAAC,CAACrD,IAAI,EAAEsC,WAAW,CAAC,MAAM;IAAEtC,IAAI;AAAEsC,IAAAA,WAAAA;AAAY,GAAC,CAAC,CAAC,CAAA;AACjF;;;;"}
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":["../../src/index.ts"],"sourcesContent":["import * as babel from '@babel/core';\nimport solid from 'babel-preset-solid';\nimport { readFileSync } from 'fs';\nimport { mergeAndConcat } from 'merge-anything';\nimport { createRequire } from 'module';\nimport solidRefresh from 'solid-refresh/babel';\nimport { createFilter } from 'vite';\nimport type { Alias, AliasOptions, Plugin, FilterPattern } from 'vite';\nimport { crawlFrameworkPkgs } from 'vitefu';\n\nconst require = createRequire(import.meta.url);\n\nconst runtimePublicPath = '/@solid-refresh';\nconst runtimeFilePath = require.resolve('solid-refresh/dist/solid-refresh.mjs');\nconst runtimeCode = readFileSync(runtimeFilePath, 'utf-8');\n\n/** Possible options for the extensions property */\nexport interface ExtensionOptions {\n typescript?: boolean;\n}\n\n/** Configuration options for vite-plugin-solid. */\nexport interface Options {\n /**\n * A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files\n * the plugin should operate on.\n */\n include?: FilterPattern;\n /**\n * A [picomatch](https://github.com/micromatch/picomatch) pattern, or array of patterns, which specifies the files\n * to be ignored by the plugin.\n */\n exclude?: FilterPattern;\n /**\n * This will inject solid-js/dev in place of solid-js in dev mode. Has no\n * effect in prod. If set to `false`, it won't inject it in dev. This is\n * useful for extra logs and debugging.\n *\n * @default true\n */\n dev: boolean;\n /**\n * This will force SSR code in the produced files. This is experiemental\n * and mostly not working yet.\n *\n * @default false\n */\n ssr: boolean;\n\n /**\n * This will inject HMR runtime in dev mode. Has no effect in prod. If\n * set to `false`, it won't inject the runtime in dev.\n *\n * @default true\n */\n hot: boolean;\n /**\n * This registers additional extensions that should be processed by\n * vite-plugin-solid.\n *\n * @default undefined\n */\n extensions?: (string | [string, ExtensionOptions])[];\n /**\n * Pass any additional babel transform options. They will be merged with\n * the transformations required by Solid.\n *\n * @default {}\n */\n babel:\n | babel.TransformOptions\n | ((source: string, id: string, ssr: boolean) => babel.TransformOptions)\n | ((source: string, id: string, ssr: boolean) => Promise<babel.TransformOptions>);\n /**\n * Pass any additional [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/tree/main/packages/babel-plugin-jsx-dom-expressions#plugin-options).\n * They will be merged with the defaults sets by [babel-preset-solid](https://github.com/solidjs/solid/blob/main/packages/babel-preset-solid/index.js#L8-L25).\n *\n * @default {}\n */\n solid: {\n /**\n * Removed unnecessary closing tags from template strings. More info here:\n * https://github.com/solidjs/solid/blob/main/CHANGELOG.md#smaller-templates\n *\n * @default false\n */\n omitNestedClosingTags: boolean;\n\n /**\n * The name of the runtime module to import the methods from.\n *\n * @default \"solid-js/web\"\n */\n moduleName?: string;\n\n /**\n * The output mode of the compiler.\n * Can be:\n * - \"dom\" is standard output\n * - \"ssr\" is for server side rendering of strings.\n * - \"universal\" is for using custom renderers from solid-js/universal\n *\n * @default \"dom\"\n */\n generate?: 'ssr' | 'dom' | 'universal';\n\n /**\n * Indicate whether the output should contain hydratable markers.\n *\n * @default false\n */\n hydratable?: boolean;\n\n /**\n * Boolean to indicate whether to enable automatic event delegation on camelCase.\n *\n * @default true\n */\n delegateEvents?: boolean;\n\n /**\n * Boolean indicates whether smart conditional detection should be used.\n * This optimizes simple boolean expressions and ternaries in JSX.\n *\n * @default true\n */\n wrapConditionals?: boolean;\n\n /**\n * Boolean indicates whether to set current render context on Custom Elements and slots.\n * Useful for seemless Context API with Web Components.\n *\n * @default true\n */\n contextToCustomElements?: boolean;\n\n /**\n * Array of Component exports from module, that aren't included by default with the library.\n * This plugin will automatically import them if it comes across them in the JSX.\n *\n * @default [\"For\",\"Show\",\"Switch\",\"Match\",\"Suspense\",\"SuspenseList\",\"Portal\",\"Index\",\"Dynamic\",\"ErrorBoundary\"]\n */\n builtIns?: string[];\n };\n}\n\nfunction getExtension(filename: string): string {\n const index = filename.lastIndexOf('.');\n return index < 0 ? '' : filename.substring(index).replace(/\\?.+$/, '');\n}\nfunction containsSolidField(fields: Record<string, any>) {\n const keys = Object.keys(fields);\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n if (key === 'solid') return true;\n if (typeof fields[key] === 'object' && fields[key] != null && containsSolidField(fields[key]))\n return true;\n }\n return false;\n}\n\nfunction getJestDomExport(setupFiles: string[]) {\n return setupFiles?.some((path) => /jest-dom/.test(path))\n ? undefined\n : ['@testing-library/jest-dom/vitest', '@testing-library/jest-dom/extend-expect'].find(\n (path) => {\n try {\n require.resolve(path);\n return true;\n } catch (e) {\n return false;\n }\n },\n );\n}\n\nexport default function solidPlugin(options: Partial<Options> = {}): Plugin {\n const filter = createFilter(options.include, options.exclude);\n\n let needHmr = false;\n let replaceDev = false;\n let projectRoot = process.cwd();\n\n return {\n name: 'solid',\n enforce: 'pre',\n\n async config(userConfig, { command }) {\n // We inject the dev mode only if the user explicitely wants it or if we are in dev (serve) mode\n replaceDev = options.dev === true || (options.dev !== false && command === 'serve');\n projectRoot = userConfig.root;\n\n if (!userConfig.resolve) userConfig.resolve = {};\n userConfig.resolve.alias = normalizeAliases(userConfig.resolve && userConfig.resolve.alias);\n\n const solidPkgsConfig = await crawlFrameworkPkgs({\n viteUserConfig: userConfig,\n root: projectRoot || process.cwd(),\n isBuild: command === 'build',\n isFrameworkPkgByJson(pkgJson) {\n return containsSolidField(pkgJson.exports || {});\n },\n });\n\n // fix for bundling dev in production\n const nestedDeps = replaceDev\n ? ['solid-js', 'solid-js/web', 'solid-js/store', 'solid-js/html', 'solid-js/h']\n : [];\n\n const test = (userConfig as any).test || {};\n\n if (userConfig.mode === 'test') {\n // to simplify the processing of the config, we normalize the setupFiles to an array\n const userSetupFiles: string[] =\n typeof test.setupFiles === 'string' ? [test.setupFiles] : test.setupFiles || [];\n\n if (!test.environment && !options.ssr) {\n test.environment = 'jsdom';\n }\n\n test.server = test.server || {};\n test.server.deps = test.server.deps || {};\n if (!test.server.deps.inline?.find((item: string | RegExp) => /solid-js/.test(item.toString()))) {\n test.server.deps.inline = [...(test.server.deps.inline || []), /solid-js/];\n }\n\n const jestDomImport = getJestDomExport(userSetupFiles);\n if (jestDomImport) {\n test.setupFiles = [...userSetupFiles, jestDomImport];\n }\n }\n\n return {\n /**\n * We only need esbuild on .ts or .js files.\n * .tsx & .jsx files are handled by us\n */\n // esbuild: { include: /\\.ts$/ },\n resolve: {\n conditions: [\n 'solid',\n ...(replaceDev ? ['development'] : []),\n ...(userConfig.mode === 'test' && !options.ssr ? ['browser'] : []),\n ],\n dedupe: nestedDeps,\n alias: [{ find: /^solid-refresh$/, replacement: runtimePublicPath }],\n },\n optimizeDeps: {\n include: [...nestedDeps, ...solidPkgsConfig.optimizeDeps.include],\n exclude: solidPkgsConfig.optimizeDeps.exclude,\n },\n ssr: solidPkgsConfig.ssr,\n ...(test.server ? { test } : {}),\n };\n },\n\n configResolved(config) {\n needHmr = config.command === 'serve' && config.mode !== 'production' && options.hot !== false;\n },\n\n resolveId(id) {\n if (id === runtimePublicPath) return id;\n },\n\n load(id) {\n if (id === runtimePublicPath) return runtimeCode;\n },\n\n async transform(source, id, transformOptions) {\n const isSsr = transformOptions && transformOptions.ssr;\n const currentFileExtension = getExtension(id);\n\n const extensionsToWatch = options.extensions || [];\n const allExtensions = extensionsToWatch.map((extension) =>\n // An extension can be a string or a tuple [extension, options]\n typeof extension === 'string' ? extension : extension[0],\n );\n\n if (!filter(id) || !(/\\.[mc]?[tj]sx$/i.test(id) || allExtensions.includes(currentFileExtension))) {\n return null;\n }\n\n const inNodeModules = /node_modules/.test(id);\n\n let solidOptions: { generate: 'ssr' | 'dom'; hydratable: boolean };\n\n if (options.ssr) {\n if (isSsr) {\n solidOptions = { generate: 'ssr', hydratable: true };\n } else {\n solidOptions = { generate: 'dom', hydratable: true };\n }\n } else {\n solidOptions = { generate: 'dom', hydratable: false };\n }\n\n id = id.replace(/\\?.+$/, '');\n\n // We need to know if the current file extension has a typescript options tied to it\n const shouldBeProcessedWithTypescript = /\\.[mc]?tsx$/i.test(id) || extensionsToWatch.some((extension) => {\n if (typeof extension === 'string') {\n return extension.includes('tsx');\n }\n\n const [extensionName, extensionOptions] = extension;\n if (extensionName !== currentFileExtension) return false;\n\n return extensionOptions.typescript;\n });\n const plugins: NonNullable<NonNullable<babel.TransformOptions['parserOpts']>['plugins']> = ['jsx']\n\n if (shouldBeProcessedWithTypescript) {\n plugins.push('typescript');\n }\n\n const opts: babel.TransformOptions = {\n root: projectRoot,\n filename: id,\n sourceFileName: id,\n presets: [[solid, { ...solidOptions, ...(options.solid || {}) }]],\n plugins: needHmr && !isSsr && !inNodeModules ? [[solidRefresh, { bundler: 'vite' }]] : [],\n ast: false,\n sourceMaps: true,\n configFile: false,\n babelrc: false,\n parserOpts: {\n plugins,\n },\n };\n\n // Default value for babel user options\n let babelUserOptions: babel.TransformOptions = {};\n\n if (options.babel) {\n if (typeof options.babel === 'function') {\n const babelOptions = options.babel(source, id, isSsr);\n babelUserOptions = babelOptions instanceof Promise ? await babelOptions : babelOptions;\n } else {\n babelUserOptions = options.babel;\n }\n }\n\n const babelOptions = mergeAndConcat(babelUserOptions, opts) as babel.TransformOptions;\n\n const { code, map } = await babel.transformAsync(source, babelOptions);\n\n return { code, map };\n },\n };\n}\n\n/**\n * This basically normalize all aliases of the config into\n * the array format of the alias.\n *\n * eg: alias: { '@': 'src/' } => [{ find: '@', replacement: 'src/' }]\n */\nfunction normalizeAliases(alias: AliasOptions = []): Alias[] {\n return Array.isArray(alias)\n ? alias\n : Object.entries(alias).map(([find, replacement]) => ({ find, replacement }));\n}\n"],"names":["require","createRequire","import","meta","url","runtimePublicPath","runtimeFilePath","resolve","runtimeCode","readFileSync","getExtension","filename","index","lastIndexOf","substring","replace","containsSolidField","fields","keys","Object","i","length","key","getJestDomExport","setupFiles","some","path","test","undefined","find","e","solidPlugin","options","filter","createFilter","include","exclude","needHmr","replaceDev","projectRoot","process","cwd","name","enforce","config","userConfig","command","dev","root","alias","normalizeAliases","solidPkgsConfig","crawlFrameworkPkgs","viteUserConfig","isBuild","isFrameworkPkgByJson","pkgJson","exports","nestedDeps","mode","userSetupFiles","environment","ssr","server","deps","inline","item","toString","jestDomImport","conditions","dedupe","replacement","optimizeDeps","configResolved","hot","resolveId","id","load","transform","source","transformOptions","isSsr","currentFileExtension","extensionsToWatch","extensions","allExtensions","map","extension","includes","inNodeModules","solidOptions","generate","hydratable","shouldBeProcessedWithTypescript","extensionName","extensionOptions","typescript","plugins","push","opts","sourceFileName","presets","solid","solidRefresh","bundler","ast","sourceMaps","configFile","babelrc","parserOpts","babelUserOptions","babel","babelOptions","Promise","mergeAndConcat","code","transformAsync","Array","isArray","entries"],"mappings":";;;;;;;;;AAUA,MAAMA,OAAO,GAAGC,aAAa,CAACC,M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AAI,EAAE0C,WAAW,CAAC,MAAM;IAAE1C,IAAI;AAAE0C,IAAAA,WAAAA;AAAY,GAAC,CAAC,CAAC,CAAA;AACjF;;;;"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as babel from '@babel/core';
|
|
2
2
|
import type { Plugin, FilterPattern } from 'vite';
|
|
3
3
|
/** Possible options for the extensions property */
|
|
4
4
|
export interface ExtensionOptions {
|
|
@@ -51,119 +51,7 @@ export interface Options {
|
|
|
51
51
|
*
|
|
52
52
|
* @default {}
|
|
53
53
|
*/
|
|
54
|
-
babel: TransformOptions | ((source: string, id: string, ssr: boolean) => TransformOptions) | ((source: string, id: string, ssr: boolean) => Promise<TransformOptions>);
|
|
55
|
-
typescript: {
|
|
56
|
-
/**
|
|
57
|
-
* Forcibly enables jsx parsing. Otherwise angle brackets will be treated as
|
|
58
|
-
* typescript's legacy type assertion var foo = <string>bar;. Also, isTSX:
|
|
59
|
-
* true requires allExtensions: true.
|
|
60
|
-
*
|
|
61
|
-
* @default false
|
|
62
|
-
*/
|
|
63
|
-
isTSX?: boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Replace the function used when compiling JSX expressions. This is so that
|
|
66
|
-
* we know that the import is not a type import, and should not be removed.
|
|
67
|
-
*
|
|
68
|
-
* @default React
|
|
69
|
-
*/
|
|
70
|
-
jsxPragma?: string;
|
|
71
|
-
/**
|
|
72
|
-
* Replace the function used when compiling JSX fragment expressions. This
|
|
73
|
-
* is so that we know that the import is not a type import, and should not
|
|
74
|
-
* be removed.
|
|
75
|
-
*
|
|
76
|
-
* @default React.Fragment
|
|
77
|
-
*/
|
|
78
|
-
jsxPragmaFrag?: string;
|
|
79
|
-
/**
|
|
80
|
-
* Indicates that every file should be parsed as TS or TSX (depending on the
|
|
81
|
-
* isTSX option).
|
|
82
|
-
*
|
|
83
|
-
* @default false
|
|
84
|
-
*/
|
|
85
|
-
allExtensions?: boolean;
|
|
86
|
-
/**
|
|
87
|
-
* Enables compilation of TypeScript namespaces.
|
|
88
|
-
*
|
|
89
|
-
* @default uses the default set by @babel/plugin-transform-typescript.
|
|
90
|
-
*/
|
|
91
|
-
allowNamespaces?: boolean;
|
|
92
|
-
/**
|
|
93
|
-
* When enabled, type-only class fields are only removed if they are
|
|
94
|
-
* prefixed with the declare modifier:
|
|
95
|
-
*
|
|
96
|
-
* > NOTE: This will be enabled by default in Babel 8
|
|
97
|
-
*
|
|
98
|
-
* @default false
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* ```ts
|
|
102
|
-
* class A {
|
|
103
|
-
* declare foo: string; // Removed
|
|
104
|
-
* bar: string; // Initialized to undefined
|
|
105
|
-
* prop?: string; // Initialized to undefined
|
|
106
|
-
* prop1!: string // Initialized to undefined
|
|
107
|
-
* }
|
|
108
|
-
* ```
|
|
109
|
-
*/
|
|
110
|
-
allowDeclareFields?: boolean;
|
|
111
|
-
/**
|
|
112
|
-
* When set to true, the transform will only remove type-only imports
|
|
113
|
-
* (introduced in TypeScript 3.8). This should only be used if you are using
|
|
114
|
-
* TypeScript >= 3.8.
|
|
115
|
-
*
|
|
116
|
-
* @default false
|
|
117
|
-
*/
|
|
118
|
-
onlyRemoveTypeImports?: boolean;
|
|
119
|
-
/**
|
|
120
|
-
* When set to true, Babel will inline enum values rather than using the
|
|
121
|
-
* usual enum output:
|
|
122
|
-
*
|
|
123
|
-
* This option differs from TypeScript's --isolatedModules behavior, which
|
|
124
|
-
* ignores the const modifier and compiles them as normal enums, and aligns
|
|
125
|
-
* Babel's behavior with TypeScript's default behavior.
|
|
126
|
-
*
|
|
127
|
-
* ```ts
|
|
128
|
-
* // Input
|
|
129
|
-
* const enum Animals {
|
|
130
|
-
* Fish
|
|
131
|
-
* }
|
|
132
|
-
* console.log(Animals.Fish);
|
|
133
|
-
*
|
|
134
|
-
* // Default output
|
|
135
|
-
* var Animals;
|
|
136
|
-
*
|
|
137
|
-
* (function (Animals) {
|
|
138
|
-
* Animals[Animals["Fish"] = 0] = "Fish";
|
|
139
|
-
* })(Animals || (Animals = {}));
|
|
140
|
-
*
|
|
141
|
-
* console.log(Animals.Fish);
|
|
142
|
-
*
|
|
143
|
-
* // `optimizeConstEnums` output
|
|
144
|
-
* console.log(0);
|
|
145
|
-
* ```
|
|
146
|
-
*
|
|
147
|
-
* However, when exporting a const enum Babel will compile it to a plain
|
|
148
|
-
* object literal so that it doesn't need to rely on cross-file analysis
|
|
149
|
-
* when compiling it:
|
|
150
|
-
*
|
|
151
|
-
* ```ts
|
|
152
|
-
* // Input
|
|
153
|
-
* export const enum Animals {
|
|
154
|
-
* Fish,
|
|
155
|
-
* }
|
|
156
|
-
*
|
|
157
|
-
* // `optimizeConstEnums` output
|
|
158
|
-
* export var Animals = {
|
|
159
|
-
* Fish: 0,
|
|
160
|
-
* };
|
|
161
|
-
* ```
|
|
162
|
-
*
|
|
163
|
-
* @default false
|
|
164
|
-
*/
|
|
165
|
-
optimizeConstEnums?: boolean;
|
|
166
|
-
};
|
|
54
|
+
babel: babel.TransformOptions | ((source: string, id: string, ssr: boolean) => babel.TransformOptions) | ((source: string, id: string, ssr: boolean) => Promise<babel.TransformOptions>);
|
|
167
55
|
/**
|
|
168
56
|
* Pass any additional [babel-plugin-jsx-dom-expressions](https://github.com/ryansolid/dom-expressions/tree/main/packages/babel-plugin-jsx-dom-expressions#plugin-options).
|
|
169
57
|
* They will be merged with the defaults sets by [babel-preset-solid](https://github.com/solidjs/solid/blob/main/packages/babel-preset-solid/index.js#L8-L25).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-plugin-solid",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.9.0",
|
|
4
4
|
"description": "solid-js integration plugin for vite 3/4/5",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -36,7 +36,6 @@
|
|
|
36
36
|
"homepage": "https://github.com/solidjs/vite-plugin-solid#readme",
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@babel/core": "^7.23.3",
|
|
39
|
-
"@babel/preset-typescript": "^7.23.3",
|
|
40
39
|
"@types/babel__core": "^7.20.4",
|
|
41
40
|
"babel-preset-solid": "^1.8.4",
|
|
42
41
|
"merge-anything": "^5.1.7",
|
|
@@ -44,7 +43,7 @@
|
|
|
44
43
|
"vitefu": "^0.2.5"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
|
-
"@babel/
|
|
46
|
+
"@babel/preset-typescript": "^7.23.3",
|
|
48
47
|
"@babel/preset-env": "^7.23.3",
|
|
49
48
|
"@rollup/plugin-babel": "^6.0.4",
|
|
50
49
|
"@rollup/plugin-commonjs": "^25.0.7",
|
|
@@ -59,9 +58,15 @@
|
|
|
59
58
|
"vite": "^5.0.0"
|
|
60
59
|
},
|
|
61
60
|
"peerDependencies": {
|
|
61
|
+
"@testing-library/jest-dom": "^5.16.6 || ^5.17.0 || ^6.*",
|
|
62
62
|
"solid-js": "^1.7.2",
|
|
63
63
|
"vite": "^3.0.0 || ^4.0.0 || ^5.0.0"
|
|
64
64
|
},
|
|
65
|
+
"peerDependencyMeta": {
|
|
66
|
+
"@testing-library/jest-dom": {
|
|
67
|
+
"optional": true
|
|
68
|
+
}
|
|
69
|
+
},
|
|
65
70
|
"packageManager": "pnpm@7.18.1",
|
|
66
71
|
"scripts": {
|
|
67
72
|
"build": "rollup -c && tsc --emitDeclarationOnly",
|