mirror of
https://github.com/developit/microbundle.git
synced 2026-01-18 13:56:35 +00:00
Support for scoped packages - remove scope from the name & remove it from dist location
This commit is contained in:
parent
932acd640b
commit
a1e05992ca
@ -24,7 +24,8 @@ const readFile = promisify(fs.readFile);
|
||||
const stat = promisify(fs.stat);
|
||||
const isDir = name => stat(name).then( stats => stats.isDirectory() ).catch( () => false );
|
||||
const isFile = name => stat(name).then( stats => stats.isFile() ).catch( () => false );
|
||||
const safeVariableName = name => camelCase(name.toLowerCase().replace(/((^[^a-zA-Z]+)|[^\w.-])|([^a-zA-Z0-9]+$)/g, ''));
|
||||
const removeScope = name => name.replace(/^@.*\//, '');
|
||||
const safeVariableName = name => camelCase(removeScope(name).toLowerCase().replace(/((^[^a-zA-Z]+)|[^\w.-])|([^a-zA-Z0-9]+$)/g, ''));
|
||||
|
||||
const WATCH_OPTS = {
|
||||
exclude: 'node_modules/**'
|
||||
@ -55,7 +56,7 @@ export default async function microbundle(options) {
|
||||
|
||||
let main = resolve(cwd, options.output || options.pkg.main || 'dist');
|
||||
if (!main.match(/\.[a-z]+$/) || await isDir(main)) {
|
||||
main = resolve(main, `${options.pkg.name}.js`);
|
||||
main = resolve(main, `${removeScope(options.pkg.name)}.js`);
|
||||
}
|
||||
options.output = main;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user