Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -482,8 +482,8 @@ function createConfig(options, entry, format, writeMeta) {
if (name instanceof RegExp) name = name.source;

// valid JS identifiers are usually library globals:
if (name.match(/^[a-z_$][a-z0-9_$]*$/)) {
globals[name] = name;
if (name.match(/^[a-z_$][a-z0-9_\-$]*$/)) {
globals[name] = camelCase(name);
}
return globals;
}, {});
Expand Down
48 changes: 48 additions & 0 deletions test/__snapshots__/index.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,54 @@ exports[`fixtures build basic-css with microbundle 6`] = `
"
`;

exports[`fixtures build basic-dashed-external with microbundle 1`] = `
"Used script: microbundle

Directory tree:

basic-dashed-external
dist
basic-dashed-external.esm.js
basic-dashed-external.esm.js.map
basic-dashed-external.js
basic-dashed-external.js.map
basic-dashed-external.umd.js
basic-dashed-external.umd.js.map
package.json
src
index.js
two.js


Build \\"basicDashedExternal\\" to dist:
248 B: basic-dashed-external.js.gz
188 B: basic-dashed-external.js.br
214 B: basic-dashed-external.esm.js.gz
164 B: basic-dashed-external.esm.js.br
349 B: basic-dashed-external.umd.js.gz
281 B: basic-dashed-external.umd.js.br"
`;

exports[`fixtures build basic-dashed-external with microbundle 2`] = `6`;

exports[`fixtures build basic-dashed-external with microbundle 3`] = `
"import r from\\"tiny-glob\\";var e=function(){try{var r=arguments;return Promise.resolve([].slice.call(r).reduce(function(r,e){return r+e},0))}catch(r){return Promise.reject(r)}};console.log(r);export default function(){try{var r=arguments,t=[].slice.call(r);return Promise.resolve(e.apply(void 0,t)).then(function(r){return Promise.resolve(e.apply(void 0,t)).then(function(e){return[r,e]})})}catch(r){return Promise.reject(r)}}
//# sourceMappingURL=basic-dashed-external.esm.js.map
"
`;

exports[`fixtures build basic-dashed-external with microbundle 4`] = `
"var e,r=(e=require(\\"tiny-glob\\"))&&\\"object\\"==typeof e&&\\"default\\"in e?e.default:e,t=function(){try{var e=arguments;return Promise.resolve([].slice.call(e).reduce(function(e,r){return e+r},0))}catch(e){return Promise.reject(e)}};console.log(r),module.exports=function(){try{var e=arguments,r=[].slice.call(e);return Promise.resolve(t.apply(void 0,r)).then(function(e){return Promise.resolve(t.apply(void 0,r)).then(function(r){return[e,r]})})}catch(e){return Promise.reject(e)}};
//# sourceMappingURL=basic-dashed-external.js.map
"
`;

exports[`fixtures build basic-dashed-external with microbundle 5`] = `
"!function(e,t){\\"object\\"==typeof exports&&\\"undefined\\"!=typeof module?module.exports=t(require(\\"tiny-glob\\")):\\"function\\"==typeof define&&define.amd?define([\\"tiny-glob\\"],t):(e=e||self).basicDashedExternal=t(e.tinyGlob)}(this,function(e){e=e&&Object.prototype.hasOwnProperty.call(e,\\"default\\")?e.default:e;var t=function(){try{var e=arguments;return Promise.resolve([].slice.call(e).reduce(function(e,t){return e+t},0))}catch(e){return Promise.reject(e)}};return console.log(e),function(){try{var e=arguments,r=[].slice.call(e);return Promise.resolve(t.apply(void 0,r)).then(function(e){return Promise.resolve(t.apply(void 0,r)).then(function(t){return[e,t]})})}catch(e){return Promise.reject(e)}}});
//# sourceMappingURL=basic-dashed-external.umd.js.map
"
`;

exports[`fixtures build basic-flow with microbundle 1`] = `
"Used script: microbundle

Expand Down
9 changes: 9 additions & 0 deletions test/fixtures/basic-dashed-external/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "basic-dashed-external",
"scripts": {
"build": "microbundle"
},
"dependencies": {
"tiny-glob": "^0.2.6"
}
}
8 changes: 8 additions & 0 deletions test/fixtures/basic-dashed-external/src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import tinyglob from 'tiny-glob';
console.log(tinyglob);

import { two } from './two';

export default async function(...args) {
return [await two(...args), await two(...args)];
}
3 changes: 3 additions & 0 deletions test/fixtures/basic-dashed-external/src/two.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export async function two(...args) {
return args.reduce((total, value) => total + value, 0);
}