Skip to content

Commit

Permalink
remove default extension mapping (#1571)
Browse files Browse the repository at this point in the history
  • Loading branch information
FredKSchott committed Nov 10, 2020
1 parent 3632b8c commit ceca955
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 28 deletions.
23 changes: 1 addition & 22 deletions snowpack/src/build/file-urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,6 @@ import path from 'path';
import {MountEntry, SnowpackConfig} from '../types/snowpack';
import {getExt, replaceExt} from '../util';

export const defaultFileExtensionMapping = {
'.mjs': '.js',
'.jsx': '.js',
'.ts': '.js',
'.tsx': '.js',
'.vue': '.js',
'.svelte': '.js',
'.mdx': '.js',
'.svx': '.js',
'.elm': '.js',
'.yaml': '.json',
'.toml': '.json',
'.php': '.html',
'.md': '.html',
'.ejs': '.html',
'.njk': '.html',
'.scss': '.css',
'.sass': '.css',
'.less': '.css',
};

/**
* Map a file path to the hosted URL for a given "mount" entry.
*/
Expand All @@ -44,7 +23,7 @@ export function getUrlForFileMount({
baseExt,
mountEntry.static
? baseExt
: config._extensionMap[baseExt] || defaultFileExtensionMapping[baseExt] || baseExt,
: config._extensionMap[baseExt] || baseExt,
);
}

Expand Down
4 changes: 2 additions & 2 deletions snowpack/src/build/import-resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import path from 'path';
import url from 'url';
import {ImportMap, SnowpackConfig} from '../types/snowpack';
import {findMatchingAliasEntry, getExt, replaceExt} from '../util';
import {defaultFileExtensionMapping, getUrlForFile} from './file-urls';
import {getUrlForFile} from './file-urls';

const cwd = process.cwd();

Expand Down Expand Up @@ -32,7 +32,7 @@ function resolveSourceSpecifier(spec: string, stats: fs.Stats | false, config: S
}
// Transform the file extension (from input to output)
const {baseExt} = getExt(spec);
const extToReplace = config._extensionMap[baseExt] || defaultFileExtensionMapping[baseExt];
const extToReplace = config._extensionMap[baseExt];
if (extToReplace) {
spec = replaceExt(spec, baseExt, extToReplace);
}
Expand Down
5 changes: 1 addition & 4 deletions snowpack/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {validate, ValidatorResult} from 'jsonschema';
import os from 'os';
import path from 'path';
import yargs from 'yargs-parser';
import {defaultFileExtensionMapping} from './build/file-urls';
import {logger} from './logger';
import {esbuildPlugin} from './plugins/plugin-esbuild';
import {
Expand Down Expand Up @@ -267,9 +266,7 @@ function parseScript(script: string): {scriptType: string; input: string[]; outp
} else if (cleanInput[0] === '.vue') {
cleanOutput = ['.js', '.css'];
} else if (cleanInput.length > 0) {
cleanOutput = Array.from(
new Set(cleanInput.map((ext) => defaultFileExtensionMapping[ext] || ext)),
);
cleanOutput = [...cleanInput];
}

return {
Expand Down

1 comment on commit ceca955

@vercel
Copy link

@vercel vercel bot commented on ceca955 Nov 10, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.