Skip to content

Commit

Permalink
fix dev build in prod, stop adding transform refresh to node_modules
Browse files Browse the repository at this point in the history
  • Loading branch information
ryansolid committed Dec 6, 2021
1 parent 9395b64 commit 2ea81e1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "vite-plugin-solid",
"version": "2.1.3",
"version": "2.1.4",
"description": "solid-js integration plugin for vite 2",
"type": "module",
"files": [
Expand Down Expand Up @@ -45,7 +45,7 @@
"babel-preset-solid": "^1.2.2",
"merge-anything": "^4.0.1",
"solid-js": "^1.2.2",
"solid-refresh": "^0.3.1",
"solid-refresh": "^0.3.2",
"vite": "^2.6.13"
},
"devDependencies": {
Expand Down
8 changes: 5 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,14 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
if (!userConfig.resolve) userConfig.resolve = {};
userConfig.resolve.alias = [...legacyAlias, ...normalizeAliases(userConfig.resolve?.alias)];

const nestedDeps = [
// fix for bundling dev in production
const nestedDeps = replaceDev ? [
'solid-js',
'solid-js/web',
'solid-js/store',
'solid-js/html',
'solid-js/h',
];
] : [];

return {
/**
Expand Down Expand Up @@ -293,6 +294,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
const ssr: boolean = transformOptions === true || transformOptions?.ssr;

if (!/\.[jt]sx/.test(id)) return null;
const inNodeModules = /node_modules/.test(id);

let solidOptions: { generate: 'ssr' | 'dom'; hydratable: boolean };

Expand All @@ -313,7 +315,7 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
filename: id,
sourceFileName: id,
presets: [[solid, { ...solidOptions, ...(options.solid || {}) }]],
plugins: needHmr ? [[solidRefresh, { bundler: 'vite' }]] : [],
plugins: needHmr && !inNodeModules ? [[solidRefresh, { bundler: 'vite' }]] : [],
sourceMaps: true,
// Vite handles sourcemap flattening
inputSourceMap: false as any,
Expand Down

0 comments on commit 2ea81e1

Please sign in to comment.