Skip to content

Commit

Permalink
🐛 Fix issues where the sourcemap wasn't properly set (fix #21)
Browse files Browse the repository at this point in the history
  • Loading branch information
amoutonbrady committed Nov 4, 2021
1 parent 9938081 commit d12159d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,14 +232,17 @@ export interface Options {

export default function solidPlugin(options: Partial<Options> = {}): Plugin {
let needHmr = false;
let replaceDev = false;
let projectRoot = process.cwd();

return {
name: 'solid',
enforce: 'pre',

config(userConfig, { command }): UserConfig {
// We inject the dev mode only if the user explicitely wants it or if we are in dev (serve) mode
const replaceDev = options.dev === true || (options.dev !== false && command === 'serve');
replaceDev = options.dev === true || (options.dev !== false && command === 'serve');
projectRoot = userConfig.root;

// TODO: remove when fully removed from vite
const legacyAlias = normalizeAliases(userConfig.alias);
Expand Down Expand Up @@ -304,9 +307,16 @@ export default function solidPlugin(options: Partial<Options> = {}): Plugin {
}

const opts: TransformOptions = {
babelrc: false,
configFile: false,
root: projectRoot,
filename: id,
sourceFileName: id,
presets: [[solid, { ...solidOptions, ...(options.solid || {}) }]],
plugins: needHmr ? [[solidRefresh, { bundler: 'vite' }]] : [],
sourceMaps: true,
// Vite handles sourcemap flattening
inputSourceMap: false as any,
};

if (id.includes('tsx')) {
Expand Down

0 comments on commit d12159d

Please sign in to comment.