Skip to content

Commit a1e0599

Browse files
committed
Support for scoped packages - remove scope from the name & remove it from dist location
1 parent 932acd6 commit a1e0599

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ const readFile = promisify(fs.readFile);
2424
const stat = promisify(fs.stat);
2525
const isDir = name => stat(name).then( stats => stats.isDirectory() ).catch( () => false );
2626
const isFile = name => stat(name).then( stats => stats.isFile() ).catch( () => false );
27-
const safeVariableName = name => camelCase(name.toLowerCase().replace(/((^[^a-zA-Z]+)|[^\w.-])|([^a-zA-Z0-9]+$)/g, ''));
27+
const removeScope = name => name.replace(/^@.*\//, '');
28+
const safeVariableName = name => camelCase(removeScope(name).toLowerCase().replace(/((^[^a-zA-Z]+)|[^\w.-])|([^a-zA-Z0-9]+$)/g, ''));
2829

2930
const WATCH_OPTS = {
3031
exclude: 'node_modules/**'
@@ -55,7 +56,7 @@ export default async function microbundle(options) {
5556

5657
let main = resolve(cwd, options.output || options.pkg.main || 'dist');
5758
if (!main.match(/\.[a-z]+$/) || await isDir(main)) {
58-
main = resolve(main, `${options.pkg.name}.js`);
59+
main = resolve(main, `${removeScope(options.pkg.name)}.js`);
5960
}
6061
options.output = main;
6162

0 commit comments

Comments
 (0)