vite-plugin-solid 2.1.4 → 2.2.3

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 CHANGED
@@ -1,3 +1,7 @@
1
+ <p>
2
+ <img width="100%" src="https://raw.githubusercontent.com/solidjs/vite-plugin-solid/master/banner.png" alt="Solid Vite Plugin">
3
+ </p>
4
+
1
5
  # ⚡ vite-plugin-solid
2
6
 
3
7
  A simple integration to run [solid-js](https://github.com/solidjs/solid) with [vite](https://github.com/vitejs/vite)
@@ -134,6 +138,15 @@ They will be merged with the defaults sets by [babel-preset-solid](https://githu
134
138
 
135
139
  Pass any additional [@babel/preset-typescript](https://babeljs.io/docs/en/babel-preset-typescript).
136
140
 
141
+ #### options.extensions
142
+
143
+ - Type: (string, [string, { typescript: boolean }])[]
144
+ - Default: []
145
+
146
+ An array of custom extension that will be passed through the solid compiler.
147
+ By default, the plugin only transform `jsx` and `tsx` files.
148
+ This is useful if you want to transform `mdx` files for example.
149
+
137
150
  ## Note on HMR
138
151
 
139
152
  Starting from version `1.1.0`, this plugin handle automatic HMR via [solid-refresh](https://github.com/solidjs/solid-refresh).
@@ -21,7 +21,12 @@ const runtimePublicPath = '/@solid-refresh';
21
21
  const runtimeFilePath = require$1.resolve('solid-refresh/dist/solid-refresh.mjs');
22
22
 
23
23
  const runtimeCode = fs.readFileSync(runtimeFilePath, 'utf-8');
24
- /** Configuration options for vite-plugin-solid. */
24
+ /** Possible options for the extensions property */
25
+
26
+ function getExtension(filename) {
27
+ const index = filename.lastIndexOf('.');
28
+ return index < 0 ? '' : filename.substring(index);
29
+ }
25
30
 
26
31
  function solidPlugin(options = {}) {
27
32
  let needHmr = false;
@@ -80,15 +85,21 @@ function solidPlugin(options = {}) {
80
85
  },
81
86
 
82
87
  async transform(source, id, transformOptions) {
83
- // @ts-expect-error anticipate vite changing second parameter as options object
84
- // see https://github.com/vitejs/vite/discussions/5109
85
- const ssr = transformOptions === true || (transformOptions === null || transformOptions === void 0 ? void 0 : transformOptions.ssr);
86
- if (!/\.[jt]sx/.test(id)) return null;
88
+ const isSsr = transformOptions === null || transformOptions === void 0 ? void 0 : transformOptions.ssr;
89
+ const currentFileExtension = getExtension(id);
90
+ const extensionsToWatch = [...(options.extensions || []), '.tsx', '.jsx'];
91
+ const allExtensions = extensionsToWatch.map(extension => // An extension can be a string or a tuple [extension, options]
92
+ typeof extension === 'string' ? extension : extension[0]);
93
+
94
+ if (!allExtensions.includes(currentFileExtension)) {
95
+ return null;
96
+ }
97
+
87
98
  const inNodeModules = /node_modules/.test(id);
88
99
  let solidOptions;
89
100
 
90
101
  if (options.ssr) {
91
- if (ssr) {
102
+ if (isSsr) {
92
103
  solidOptions = {
93
104
  generate: 'ssr',
94
105
  hydratable: true
@@ -115,15 +126,25 @@ function solidPlugin(options = {}) {
115
126
  presets: [[solid__default["default"], { ...solidOptions,
116
127
  ...(options.solid || {})
117
128
  }]],
118
- plugins: needHmr && !inNodeModules ? [[solidRefresh__default["default"], {
129
+ plugins: needHmr && !isSsr && !inNodeModules ? [[solidRefresh__default["default"], {
119
130
  bundler: 'vite'
120
- }]] : [],
131
+ }]] : undefined,
121
132
  sourceMaps: true,
122
133
  // Vite handles sourcemap flattening
123
134
  inputSourceMap: false
124
- };
135
+ }; // We need to know if the current file extension has a typescript options tied to it
136
+
137
+ const shouldBeProcessedWithTypescript = extensionsToWatch.some(extension => {
138
+ if (typeof extension === 'string') {
139
+ return extension.includes('tsx');
140
+ }
141
+
142
+ const [extensionName, extensionOptions] = extension;
143
+ if (extensionName !== currentFileExtension) return false;
144
+ return extensionOptions.typescript;
145
+ });
125
146
 
126
- if (id.includes('tsx')) {
147
+ if (shouldBeProcessedWithTypescript) {
127
148
  opts.presets.push([ts__default["default"], options.typescript || {}]);
128
149
  } // Default value for babel user options
129
150
 
@@ -132,7 +153,7 @@ function solidPlugin(options = {}) {
132
153
 
133
154
  if (options.babel) {
134
155
  if (typeof options.babel === 'function') {
135
- const babelOptions = options.babel(source, id, ssr);
156
+ const babelOptions = options.babel(source, id, isSsr);
136
157
  babelUserOptions = babelOptions instanceof Promise ? await babelOptions : babelOptions;
137
158
  } else {
138
159
  babelUserOptions = options.babel;
@@ -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.js';\nimport type { Alias, AliasOptions, Plugin, UserConfig } from 'vite';\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/** Configuration options for vite-plugin-solid. */\nexport interface Options {\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 * 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 * 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 * 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 *\n * @default \"dom\"\n */\n generate?: 'ssr' | 'dom';\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\nexport default function solidPlugin(options: Partial<Options> = {}): Plugin {\n let needHmr = false;\n let replaceDev = false;\n let projectRoot = process.cwd();\n\n return {\n name: 'solid',\n enforce: 'pre',\n\n config(userConfig, { command }): UserConfig {\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 // TODO: remove when fully removed from vite\n const legacyAlias = normalizeAliases(userConfig.alias);\n\n if (!userConfig.resolve) userConfig.resolve = {};\n userConfig.resolve.alias = [...legacyAlias, ...normalizeAliases(userConfig.resolve?.alias)];\n\n // fix for bundling dev in production\n const nestedDeps = replaceDev ? [\n 'solid-js',\n 'solid-js/web',\n 'solid-js/store',\n 'solid-js/html',\n 'solid-js/h',\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: ['solid', ...(replaceDev ? ['development'] : [])],\n dedupe: nestedDeps,\n alias: [{ find: /^solid-refresh$/, replacement: runtimePublicPath }],\n },\n optimizeDeps: {\n include: nestedDeps,\n },\n } as UserConfig;\n },\n\n configResolved(config) {\n needHmr = config.command === 'serve' && !config.isProduction && 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 // @ts-expect-error anticipate vite changing second parameter as options object\n // see https://github.com/vitejs/vite/discussions/5109\n const ssr: boolean = transformOptions === true || transformOptions?.ssr;\n\n if (!/\\.[jt]sx/.test(id)) return null;\n const inNodeModules = /node_modules/.test(id);\n\n let solidOptions: { generate: 'ssr' | 'dom'; hydratable: boolean };\n\n if (options.ssr) {\n if (ssr) {\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 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 && !inNodeModules ? [[solidRefresh, { bundler: 'vite' }]] : [],\n sourceMaps: true,\n // Vite handles sourcemap flattening\n inputSourceMap: false as any,\n };\n\n if (id.includes('tsx')) {\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, ssr);\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","solidPlugin","options","needHmr","replaceDev","projectRoot","process","cwd","name","enforce","config","userConfig","command","dev","root","legacyAlias","normalizeAliases","alias","nestedDeps","esbuild","include","conditions","dedupe","find","replacement","optimizeDeps","configResolved","isProduction","hot","resolveId","id","load","transform","source","transformOptions","ssr","test","inNodeModules","solidOptions","generate","hydratable","opts","babelrc","configFile","filename","sourceFileName","presets","solid","plugins","solidRefresh","bundler","sourceMaps","inputSourceMap","includes","push","ts","typescript","babelUserOptions","babel","babelOptions","Promise","mergeAndConcat","code","map","transformAsync","Array","isArray","Object","entries"],"mappings":";;;;;;;;;;;;;;;;AASA,MAAMA,SAAO,GAAGC,sBAAa,CAACC,oMAAD,CAA7B;;AAEA,MAAMC,iBAAiB,GAAG,iBAA1B;;AACA,MAAMC,eAAe,GAAGJ,SAAO,CAACK,OAAR,CAAgB,sCAAhB,CAAxB;;AACA,MAAMC,WAAW,GAAGC,eAAY,CAACH,eAAD,EAAkB,OAAlB,CAAhC;AAEA;;AAyNe,SAASI,WAAT,CAAqBC,OAAyB,GAAG,EAAjD,EAA6D;AAC1E,MAAIC,OAAO,GAAG,KAAd;AACA,MAAIC,UAAU,GAAG,KAAjB;AACA,MAAIC,WAAW,GAAGC,OAAO,CAACC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AACJ,gBAAD,EAAmBhB,IAAnB,CAAnC;AAEA,YAAM;AAAEqB,QAAAA,IAAF;AAAQC,QAAAA;AAAR,UAAgB,MAAMC,mBAAc,CAAC/B,MAAD,EAAS0B,YAAT,CAA1C;AAEA,aAAO;AAAEG,QAAAA,IAAF;AAAQC,QAAAA;AAAR,OAAP;AACD;;AA3GI,GAAP;AA6GD;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,SAAS/C,gBAAT,CAA0BC,KAAmB,GAAG,EAAhD,EAA6D;AAC3D,SAAOgD,KAAK,CAACC,OAAN,CAAcjD,KAAd,IACHA,KADG,GAEHkD,MAAM,CAACC,OAAP,CAAenD,KAAf,EAAsB8C,GAAtB,CAA0B,CAAC,CAACxC,IAAD,EAAOC,WAAP,CAAD,MAA0B;AAAED,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAA1B,CAA1B,CAFJ;AAGD;;;;"}
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.js';\nimport type { Alias, AliasOptions, Plugin, UserConfig } from 'vite';\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 * 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 * 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 * 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 *\n * @default \"dom\"\n */\n generate?: 'ssr' | 'dom';\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);\n}\n\nexport default function solidPlugin(options: Partial<Options> = {}): Plugin {\n let needHmr = false;\n let replaceDev = false;\n let projectRoot = process.cwd();\n\n return {\n name: 'solid',\n enforce: 'pre',\n\n config(userConfig, { command }): UserConfig {\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 // TODO: remove when fully removed from vite\n const legacyAlias = normalizeAliases(userConfig.alias);\n\n if (!userConfig.resolve) userConfig.resolve = {};\n userConfig.resolve.alias = [...legacyAlias, ...normalizeAliases(userConfig.resolve?.alias)];\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 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: ['solid', ...(replaceDev ? ['development'] : [])],\n dedupe: nestedDeps,\n alias: [{ find: /^solid-refresh$/, replacement: runtimePublicPath }],\n },\n optimizeDeps: {\n include: nestedDeps,\n },\n } as UserConfig;\n },\n\n configResolved(config) {\n needHmr = config.command === 'serve' && !config.isProduction && 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?.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 (!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 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' }]] : undefined,\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","solidPlugin","options","needHmr","replaceDev","projectRoot","process","cwd","name","enforce","config","userConfig","command","dev","root","legacyAlias","normalizeAliases","alias","nestedDeps","esbuild","include","conditions","dedupe","find","replacement","optimizeDeps","configResolved","isProduction","hot","resolveId","id","load","transform","source","transformOptions","isSsr","ssr","currentFileExtension","extensionsToWatch","extensions","allExtensions","map","extension","includes","inNodeModules","test","solidOptions","generate","hydratable","opts","babelrc","configFile","sourceFileName","presets","solid","plugins","solidRefresh","bundler","undefined","sourceMaps","inputSourceMap","shouldBeProcessedWithTypescript","some","extensionName","extensionOptions","typescript","push","ts","babelUserOptions","babel","babelOptions","Promise","mergeAndConcat","code","transformAsync","Array","isArray","Object","entries"],"mappings":";;;;;;;;;;;;;;;;AASA,MAAMA,SAAO,GAAGC,sBAAa,CAACC,oMAAD,CAA7B;;AAEA,MAAMC,iBAAiB,GAAG,iBAA1B;;AACA,MAAMC,eAAe,GAAGJ,SAAO,CAACK,OAAR,CAAgB,sCAAhB,CAAxB;;AACA,MAAMC,WAAW,GAAGC,eAAY,CAACH,eAAD,EAAkB,OAAlB,CAAhC;AAEA;;AAqOA,SAASI,YAAT,CAAsBC,QAAtB,EAAgD;AAC9C,QAAMC,KAAK,GAAGD,QAAQ,CAACE,WAAT,CAAqB,GAArB,CAAd;AACA,SAAOD,KAAK,GAAG,CAAR,GAAY,EAAZ,GAAiBD,QAAQ,CAACG,SAAT,CAAmBF,KAAnB,CAAxB;AACD;;AAEc,SAASG,WAAT,CAAqBC,OAAyB,GAAG,EAAjD,EAA6D;AAC1E,MAAIC,OAAO,GAAG,KAAd;AACA,MAAIC,UAAU,GAAG,KAAjB;AACA,MAAIC,WAAW,GAAGC,OAAO,CAACC,GAAR,EA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icPath = '/@solid-refresh';
13
13
  const runtimeFilePath = require.resolve('solid-refresh/dist/solid-refresh.mjs');
14
14
 
15
15
  const runtimeCode = readFileSync(runtimeFilePath, 'utf-8');
16
- /** Configuration options for vite-plugin-solid. */
16
+ /** Possible options for the extensions property */
17
+
18
+ function getExtension(filename) {
19
+ const index = filename.lastIndexOf('.');
20
+ return index < 0 ? '' : filename.substring(index);
21
+ }
17
22
 
18
23
  function solidPlugin(options = {}) {
19
24
  let needHmr = false;
@@ -72,15 +77,21 @@ function solidPlugin(options = {}) {
72
77
  },
73
78
 
74
79
  async transform(source, id, transformOptions) {
75
- // @ts-expect-error anticipate vite changing second parameter as options object
76
- // see https://github.com/vitejs/vite/discussions/5109
77
- const ssr = transformOptions === true || (transformOptions === null || transformOptions === void 0 ? void 0 : transformOptions.ssr);
78
- if (!/\.[jt]sx/.test(id)) return null;
80
+ const isSsr = transformOptions === null || transformOptions === void 0 ? void 0 : transformOptions.ssr;
81
+ const currentFileExtension = getExtension(id);
82
+ const extensionsToWatch = [...(options.extensions || []), '.tsx', '.jsx'];
83
+ const allExtensions = extensionsToWatch.map(extension => // An extension can be a string or a tuple [extension, options]
84
+ typeof extension === 'string' ? extension : extension[0]);
85
+
86
+ if (!allExtensions.includes(currentFileExtension)) {
87
+ return null;
88
+ }
89
+
79
90
  const inNodeModules = /node_modules/.test(id);
80
91
  let solidOptions;
81
92
 
82
93
  if (options.ssr) {
83
- if (ssr) {
94
+ if (isSsr) {
84
95
  solidOptions = {
85
96
  generate: 'ssr',
86
97
  hydratable: true
@@ -107,15 +118,25 @@ function solidPlugin(options = {}) {
107
118
  presets: [[solid, { ...solidOptions,
108
119
  ...(options.solid || {})
109
120
  }]],
110
- plugins: needHmr && !inNodeModules ? [[solidRefresh, {
121
+ plugins: needHmr && !isSsr && !inNodeModules ? [[solidRefresh, {
111
122
  bundler: 'vite'
112
- }]] : [],
123
+ }]] : undefined,
113
124
  sourceMaps: true,
114
125
  // Vite handles sourcemap flattening
115
126
  inputSourceMap: false
116
- };
127
+ }; // We need to know if the current file extension has a typescript options tied to it
128
+
129
+ const shouldBeProcessedWithTypescript = extensionsToWatch.some(extension => {
130
+ if (typeof extension === 'string') {
131
+ return extension.includes('tsx');
132
+ }
133
+
134
+ const [extensionName, extensionOptions] = extension;
135
+ if (extensionName !== currentFileExtension) return false;
136
+ return extensionOptions.typescript;
137
+ });
117
138
 
118
- if (id.includes('tsx')) {
139
+ if (shouldBeProcessedWithTypescript) {
119
140
  opts.presets.push([ts, options.typescript || {}]);
120
141
  } // Default value for babel user options
121
142
 
@@ -124,7 +145,7 @@ function solidPlugin(options = {}) {
124
145
 
125
146
  if (options.babel) {
126
147
  if (typeof options.babel === 'function') {
127
- const babelOptions = options.babel(source, id, ssr);
148
+ const babelOptions = options.babel(source, id, isSsr);
128
149
  babelUserOptions = babelOptions instanceof Promise ? await babelOptions : babelOptions;
129
150
  } else {
130
151
  babelUserOptions = options.babel;
@@ -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.js';\nimport type { Alias, AliasOptions, Plugin, UserConfig } from 'vite';\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/** Configuration options for vite-plugin-solid. */\nexport interface Options {\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 * 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 * 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 * 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 *\n * @default \"dom\"\n */\n generate?: 'ssr' | 'dom';\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\nexport default function solidPlugin(options: Partial<Options> = {}): Plugin {\n let needHmr = false;\n let replaceDev = false;\n let projectRoot = process.cwd();\n\n return {\n name: 'solid',\n enforce: 'pre',\n\n config(userConfig, { command }): UserConfig {\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 // TODO: remove when fully removed from vite\n const legacyAlias = normalizeAliases(userConfig.alias);\n\n if (!userConfig.resolve) userConfig.resolve = {};\n userConfig.resolve.alias = [...legacyAlias, ...normalizeAliases(userConfig.resolve?.alias)];\n\n // fix for bundling dev in production\n const nestedDeps = replaceDev ? [\n 'solid-js',\n 'solid-js/web',\n 'solid-js/store',\n 'solid-js/html',\n 'solid-js/h',\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: ['solid', ...(replaceDev ? ['development'] : [])],\n dedupe: nestedDeps,\n alias: [{ find: /^solid-refresh$/, replacement: runtimePublicPath }],\n },\n optimizeDeps: {\n include: nestedDeps,\n },\n } as UserConfig;\n },\n\n configResolved(config) {\n needHmr = config.command === 'serve' && !config.isProduction && 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 // @ts-expect-error anticipate vite changing second parameter as options object\n // see https://github.com/vitejs/vite/discussions/5109\n const ssr: boolean = transformOptions === true || transformOptions?.ssr;\n\n if (!/\\.[jt]sx/.test(id)) return null;\n const inNodeModules = /node_modules/.test(id);\n\n let solidOptions: { generate: 'ssr' | 'dom'; hydratable: boolean };\n\n if (options.ssr) {\n if (ssr) {\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 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 && !inNodeModules ? [[solidRefresh, { bundler: 'vite' }]] : [],\n sourceMaps: true,\n // Vite handles sourcemap flattening\n inputSourceMap: false as any,\n };\n\n if (id.includes('tsx')) {\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, ssr);\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","solidPlugin","options","needHmr","replaceDev","projectRoot","process","cwd","name","enforce","config","userConfig","command","dev","root","legacyAlias","normalizeAliases","alias","nestedDeps","esbuild","include","conditions","dedupe","find","replacement","optimizeDeps","configResolved","isProduction","hot","resolveId","id","load","transform","source","transformOptions","ssr","test","inNodeModules","solidOptions","generate","hydratable","opts","babelrc","configFile","filename","sourceFileName","presets","solid","plugins","solidRefresh","bundler","sourceMaps","inputSourceMap","includes","push","ts","typescript","babelUserOptions","babel","babelOptions","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,CAAlB;AACD,OAnC2C;;;AAsC5C,UAAIC,gBAAkC,GAAG,EAAzC;;AAEA,UAAIvD,OAAO,CAACwD,KAAZ,EAAmB;AACjB,YAAI,OAAOxD,OAAO,CAACwD,KAAf,KAAyB,UAA7B,EAAyC;AACvC,gBAAMC,YAAY,GAAGzD,OAAO,CAACwD,KAAR,CAAczB,MAAd,EAAsBH,EAAtB,EAA0BK,GAA1B,CAArB;AACAsB,UAAAA,gBAAgB,GAAGE,YAAY,YAAYC,OAAxB,GAAkC,MAAMD,YAAxC,GAAuDA,YAA1E;AACD,SAHD,MAGO;AACLF,UAAAA,gBAAgB,GAAGvD,OAAO,CAACwD,KAA3B;AACD;AACF;;AAED,YAAMC,YAAY,GAAGE,cAAc,CAACJ,gBAAD,EAAmBhB,IAAnB,CAAnC;AAEA,YAAM;AAAEqB,QAAAA,IAAF;AAAQC,QAAAA;AAAR,UAAgB,MAAMC,cAAc,CAAC/B,MAAD,EAAS0B,YAAT,CAA1C;AAEA,aAAO;AAAEG,QAAAA,IAAF;AAAQC,QAAAA;AAAR,OAAP;AACD;;AA3GI,GAAP;AA6GD;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,SAAS/C,gBAAT,CAA0BC,KAAmB,GAAG,EAAhD,EAA6D;AAC3D,SAAOgD,KAAK,CAACC,OAAN,CAAcjD,KAAd,IACHA,KADG,GAEHkD,MAAM,CAACC,OAAP,CAAenD,KAAf,EAAsB8C,GAAtB,CAA0B,CAAC,CAACxC,IAAD,EAAOC,WAAP,CAAD,MAA0B;AAAED,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAA1B,CAA1B,CAFJ;AAGD;;;;"}
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.js';\nimport type { Alias, AliasOptions, Plugin, UserConfig } from 'vite';\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 * 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 * 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 * 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 *\n * @default \"dom\"\n */\n generate?: 'ssr' | 'dom';\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);\n}\n\nexport default function solidPlugin(options: Partial<Options> = {}): Plugin {\n let needHmr = false;\n let replaceDev = false;\n let projectRoot = process.cwd();\n\n return {\n name: 'solid',\n enforce: 'pre',\n\n config(userConfig, { command }): UserConfig {\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 // TODO: remove when fully removed from vite\n const legacyAlias = normalizeAliases(userConfig.alias);\n\n if (!userConfig.resolve) userConfig.resolve = {};\n userConfig.resolve.alias = [...legacyAlias, ...normalizeAliases(userConfig.resolve?.alias)];\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 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: ['solid', ...(replaceDev ? ['development'] : [])],\n dedupe: nestedDeps,\n alias: [{ find: /^solid-refresh$/, replacement: runtimePublicPath }],\n },\n optimizeDeps: {\n include: nestedDeps,\n },\n } as UserConfig;\n },\n\n configResolved(config) {\n needHmr = config.command === 'serve' && !config.isProduction && 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?.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 (!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 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' }]] : undefined,\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","solidPlugin","options","needHmr","replaceDev","projectRoot","process","cwd","name","enforce","config","userConfig","command","dev","root","legacyAlias","normalizeAliases","alias","nestedDeps","esbuild","include","conditions","dedupe","find","replacement","optimizeDeps","configResolved","isProduction","hot","resolveId","id","load","transform","source","transformOptions","isSsr","ssr","currentFileExtension","extensionsToWatch","extensions","allExtensions","map","extension","includes","inNodeModules","test","solidOptions","generate","hydratable","opts","babelrc","configFile","sourceFileName","presets","solid","plugins","solidRefresh","bundler","undefined","sourceMaps","inputSourceMap","shouldBeProcessedWithTypescript","some","extensionName","extensionOptions","typescript","push","ts","babelUserOptions","babel","babelOptions","Promise","mergeAndConcat","code","transformAsync","Array","isArray","Object","entries"],"mappings":";;;;;;;;AASA,MAAMA,OAAO,GAAGC,aAAa,CAACC,MAAM,CAACC,IAAP,CAAYC,GAAb,CAA7B;;AAEA,MAAMC,iBAAiB,GAAG,iBAA1B;;AACA,MAAMC,eAAe,GAAGN,OAAO,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ACzC,MAAD,EAASqC,YAAT,CAA1C;AAEA,aAAO;AAAEG,QAAAA,IAAF;AAAQhC,QAAAA;AAAR,OAAP;AACD;;AA3HI,GAAP;AA6HD;AAED;AACA;AACA;AACA;AACA;AACA;;AACA,SAASzB,gBAAT,CAA0BC,KAAmB,GAAG,EAAhD,EAA6D;AAC3D,SAAO0D,KAAK,CAACC,OAAN,CAAc3D,KAAd,IACHA,KADG,GAEH4D,MAAM,CAACC,OAAP,CAAe7D,KAAf,EAAsBwB,GAAtB,CAA0B,CAAC,CAAClB,IAAD,EAAOC,WAAP,CAAD,MAA0B;AAAED,IAAAA,IAAF;AAAQC,IAAAA;AAAR,GAA1B,CAA1B,CAFJ;AAGD;;;;"}
@@ -1,5 +1,9 @@
1
1
  import { TransformOptions } from '@babel/core';
2
2
  import type { Plugin } from 'vite';
3
+ /** Possible options for the extensions property */
4
+ export interface ExtensionOptions {
5
+ typescript?: boolean;
6
+ }
3
7
  /** Configuration options for vite-plugin-solid. */
4
8
  export interface Options {
5
9
  /**
@@ -24,6 +28,13 @@ export interface Options {
24
28
  * @default true
25
29
  */
26
30
  hot: boolean;
31
+ /**
32
+ * This registers additional extensions that should be processed by
33
+ * vite-plugin-solid.
34
+ *
35
+ * @default undefined
36
+ */
37
+ extensions?: (string | [string, ExtensionOptions])[];
27
38
  /**
28
39
  * Pass any additional babel transform options. They will be merged with
29
40
  * the transformations required by Solid.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vite-plugin-solid",
3
- "version": "2.1.4",
3
+ "version": "2.2.3",
4
4
  "description": "solid-js integration plugin for vite 2",
5
5
  "type": "module",
6
6
  "files": [
@@ -40,26 +40,27 @@
40
40
  },
41
41
  "homepage": "https://github.com/solidjs/vite-plugin-solid#readme",
42
42
  "dependencies": {
43
- "@babel/core": "^7.16.0",
44
- "@babel/preset-typescript": "^7.16.0",
45
- "babel-preset-solid": "^1.2.6",
46
- "merge-anything": "^4.0.1",
47
- "solid-js": "^1.2.6",
48
- "solid-refresh": "^0.3.2",
49
- "vite": "^2.7.1"
43
+ "@babel/core": "^7.16.7",
44
+ "@babel/preset-typescript": "^7.16.7",
45
+ "babel-preset-solid": "^1.3.0",
46
+ "merge-anything": "^4.0.2",
47
+ "solid-js": "^1.3.0",
48
+ "solid-refresh": "^0.4.0",
49
+ "vite": "^2.7.10"
50
50
  },
51
51
  "devDependencies": {
52
- "@babel/plugin-transform-typescript": "^7.16.1",
53
- "@babel/preset-env": "^7.16.0",
52
+ "@babel/plugin-transform-typescript": "^7.16.7",
53
+ "@babel/preset-env": "^7.16.7",
54
54
  "@rollup/plugin-babel": "^5.3.0",
55
55
  "@rollup/plugin-commonjs": "^21.0.1",
56
- "@rollup/plugin-node-resolve": "^13.0.6",
56
+ "@rollup/plugin-node-resolve": "^13.1.2",
57
57
  "@skypack/package-check": "^0.2.2",
58
- "@types/babel__core": "^7.1.16",
59
- "@types/node": "^16.11.6",
60
- "prettier": "^2.4.1",
61
- "rollup": "^2.59.0",
58
+ "@types/babel__core": "^7.1.18",
59
+ "@types/node": "^17.0.7",
60
+ "prettier": "^2.5.1",
61
+ "rollup": "^2.62.0",
62
62
  "rollup-plugin-cleaner": "^1.0.0",
63
- "typescript": "^4.4.4"
64
- }
63
+ "typescript": "^4.5.4"
64
+ },
65
+ "packageManager": "pnpm@6.24.4"
65
66
  }