mirror of https://github.com/lukechilds/rollup.git
committed by
GitHub
24 changed files with 187 additions and 11 deletions
@ -0,0 +1,18 @@ |
|||||
|
// Generate strings which dereference dotted properties, but use array notation `['prop-deref']`
|
||||
|
// if the property name isn't trivial
|
||||
|
|
||||
|
const shouldUseDot = /^[a-zA-Z$_][a-zA-Z0-9$_]*$/; |
||||
|
const dereferenceString = prop => |
||||
|
prop.match(shouldUseDot) ? `.${prop}` : `['${prop}']`; |
||||
|
|
||||
|
/** |
||||
|
* returns a function which generates property dereference strings for the given name |
||||
|
* |
||||
|
* const getGlobalProp = propertyStringFor('global'); |
||||
|
* getGlobalProp('foo.bar-baz.qux') => `global.bar['bar-baz'].qux` |
||||
|
*/ |
||||
|
const propertyStringFor = objName => propName => |
||||
|
objName + propName.split('.').map(dereferenceString).join(''); |
||||
|
|
||||
|
|
||||
|
export default propertyStringFor; |
@ -0,0 +1,6 @@ |
|||||
|
module.exports = { |
||||
|
description: 'allows module name with dashes to be added to the global object', |
||||
|
options: { |
||||
|
moduleName: '@scoped/npm-package' |
||||
|
} |
||||
|
}; |
@ -0,0 +1,9 @@ |
|||||
|
define(['exports'], function (exports) { 'use strict'; |
||||
|
|
||||
|
let foo = 'foo'; |
||||
|
|
||||
|
exports.foo = foo; |
||||
|
|
||||
|
Object.defineProperty(exports, '__esModule', { value: true }); |
||||
|
|
||||
|
}); |
@ -0,0 +1,7 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
Object.defineProperty(exports, '__esModule', { value: true }); |
||||
|
|
||||
|
let foo = 'foo'; |
||||
|
|
||||
|
exports.foo = foo; |
@ -0,0 +1,3 @@ |
|||||
|
let foo = 'foo'; |
||||
|
|
||||
|
export { foo }; |
@ -0,0 +1,8 @@ |
|||||
|
(function (exports) { |
||||
|
'use strict'; |
||||
|
|
||||
|
let foo = 'foo'; |
||||
|
|
||||
|
exports.foo = foo; |
||||
|
|
||||
|
}((this['@scoped/npm-package'] = this['@scoped/npm-package'] || {}))); |
@ -0,0 +1,13 @@ |
|||||
|
(function (global, factory) { |
||||
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
||||
|
typeof define === 'function' && define.amd ? define(['exports'], factory) : |
||||
|
(factory((global['@scoped/npm-package'] = global['@scoped/npm-package'] || {}))); |
||||
|
}(this, (function (exports) { 'use strict'; |
||||
|
|
||||
|
let foo = 'foo'; |
||||
|
|
||||
|
exports.foo = foo; |
||||
|
|
||||
|
Object.defineProperty(exports, '__esModule', { value: true }); |
||||
|
|
||||
|
}))); |
@ -0,0 +1 @@ |
|||||
|
export let foo = 'foo'; |
@ -0,0 +1,6 @@ |
|||||
|
module.exports = { |
||||
|
description: 'properly dereferences properties on the global object regardless of nesting', |
||||
|
options: { |
||||
|
moduleName: 'foo.@scoped/npm-package.bar.why-would-you-do-this' |
||||
|
} |
||||
|
}; |
@ -0,0 +1,9 @@ |
|||||
|
define(['exports'], function (exports) { 'use strict'; |
||||
|
|
||||
|
let foo = 'foo'; |
||||
|
|
||||
|
exports.foo = foo; |
||||
|
|
||||
|
Object.defineProperty(exports, '__esModule', { value: true }); |
||||
|
|
||||
|
}); |
@ -0,0 +1,7 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
Object.defineProperty(exports, '__esModule', { value: true }); |
||||
|
|
||||
|
let foo = 'foo'; |
||||
|
|
||||
|
exports.foo = foo; |
@ -0,0 +1,3 @@ |
|||||
|
let foo = 'foo'; |
||||
|
|
||||
|
export { foo }; |
@ -0,0 +1,11 @@ |
|||||
|
this.foo = this.foo || {}; |
||||
|
this.foo['@scoped/npm-package'] = this.foo['@scoped/npm-package'] || {}; |
||||
|
this.foo['@scoped/npm-package'].bar = this.foo['@scoped/npm-package'].bar || {}; |
||||
|
(function (exports) { |
||||
|
'use strict'; |
||||
|
|
||||
|
let foo = 'foo'; |
||||
|
|
||||
|
exports.foo = foo; |
||||
|
|
||||
|
}((this.foo['@scoped/npm-package'].bar['why-would-you-do-this'] = this.foo['@scoped/npm-package'].bar['why-would-you-do-this'] || {}))); |
@ -0,0 +1,13 @@ |
|||||
|
(function (global, factory) { |
||||
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
||||
|
typeof define === 'function' && define.amd ? define(['exports'], factory) : |
||||
|
(factory((global.foo = global.foo || {}, global.foo['@scoped/npm-package'] = global.foo['@scoped/npm-package'] || {}, global.foo['@scoped/npm-package'].bar = global.foo['@scoped/npm-package'].bar || {}, global.foo['@scoped/npm-package'].bar['why-would-you-do-this'] = global.foo['@scoped/npm-package'].bar['why-would-you-do-this'] || {}))); |
||||
|
}(this, (function (exports) { 'use strict'; |
||||
|
|
||||
|
let foo = 'foo'; |
||||
|
|
||||
|
exports.foo = foo; |
||||
|
|
||||
|
Object.defineProperty(exports, '__esModule', { value: true }); |
||||
|
|
||||
|
}))); |
@ -0,0 +1 @@ |
|||||
|
export let foo = 'foo'; |
@ -0,0 +1,6 @@ |
|||||
|
module.exports = { |
||||
|
description: 'allows module name with dashes to be added to the global object', |
||||
|
options: { |
||||
|
moduleName: 'module-name-with-dashes' |
||||
|
} |
||||
|
}; |
@ -0,0 +1,9 @@ |
|||||
|
define(['exports'], function (exports) { 'use strict'; |
||||
|
|
||||
|
let foo = 'foo'; |
||||
|
|
||||
|
exports.foo = foo; |
||||
|
|
||||
|
Object.defineProperty(exports, '__esModule', { value: true }); |
||||
|
|
||||
|
}); |
@ -0,0 +1,7 @@ |
|||||
|
'use strict'; |
||||
|
|
||||
|
Object.defineProperty(exports, '__esModule', { value: true }); |
||||
|
|
||||
|
let foo = 'foo'; |
||||
|
|
||||
|
exports.foo = foo; |
@ -0,0 +1,3 @@ |
|||||
|
let foo = 'foo'; |
||||
|
|
||||
|
export { foo }; |
@ -0,0 +1,8 @@ |
|||||
|
(function (exports) { |
||||
|
'use strict'; |
||||
|
|
||||
|
let foo = 'foo'; |
||||
|
|
||||
|
exports.foo = foo; |
||||
|
|
||||
|
}((this['module-name-with-dashes'] = this['module-name-with-dashes'] || {}))); |
@ -0,0 +1,13 @@ |
|||||
|
(function (global, factory) { |
||||
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : |
||||
|
typeof define === 'function' && define.amd ? define(['exports'], factory) : |
||||
|
(factory((global['module-name-with-dashes'] = global['module-name-with-dashes'] || {}))); |
||||
|
}(this, (function (exports) { 'use strict'; |
||||
|
|
||||
|
let foo = 'foo'; |
||||
|
|
||||
|
exports.foo = foo; |
||||
|
|
||||
|
Object.defineProperty(exports, '__esModule', { value: true }); |
||||
|
|
||||
|
}))); |
@ -0,0 +1 @@ |
|||||
|
export let foo = 'foo'; |
Loading…
Reference in new issue