Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const path = require('path')
const notifier = require('node-notifier')
const stripAnsi = require('strip-ansi')
const {charSizes} = require('./font.js')
const rollup = require('rollup')
// Warning that this plugin requies at least rollup 0.60.0.
if (rollup.VERSION) {
let [major, minor, patch] = rollup.VERSION.split('.').map(Number)
if (major < 1 && minor < 60)
console.warn(`'rollup-plugin-notify' will not work. Rollup 0.60.0 or higher is required`)
}
// Ugly hack. There are two problems (not 100% sure but this is what's most likely going on)
// 1) Rollup apparently terminates the process immediately after error occurs.
// It calls the buildEnd callback but does not give us enough time to create the notification asynchronously.
// 2) node-notifier creates the notification by calling child_process.execFile() which is not as reliable
// as just child_process.exec(). But exec() wouldn't support multiline notifications due to inability to pass
// EOLs in cmd arguments.
// This hack creates the notification synchronously and bypassess node-notifier's internals.
// Tested on Windows 10. Not sure if the same problem/hack occurs/is-needed on other systems too.
const os = require('os')
if (os.platform() === 'win32' && os.release().startsWith('10.')) {
notifier.notify = function(options) {
const path = require('path')
const notifier = require('node-notifier')
const stripAnsi = require('strip-ansi')
const {charSizes} = require('./font.js')
const rollup = require('rollup')
// Warning that this plugin requies at least rollup 0.60.0.
if (rollup.VERSION) {
let [major, minor, patch] = rollup.VERSION.split('.').map(Number)
if (major < 1 && minor < 60)
console.warn(`'rollup-plugin-notify' will not work. Rollup 0.60.0 or higher is required`)
}
// Ugly hack. There are two problems (not 100% sure but this is what's most likely going on)
// 1) Rollup apparently terminates the process immediately after error occurs.
// It calls the buildEnd callback but does not give us enough time to create the notification asynchronously.
// 2) node-notifier creates the notification by calling child_process.execFile() which is not as reliable
// as just child_process.exec(). But exec() wouldn't support multiline notifications due to inability to pass
// EOLs in cmd arguments.
// This hack creates the notification synchronously and bypassess node-notifier's internals.
// Tested on Windows 10. Not sure if the same problem/hack occurs/is-needed on other systems too.
const os = require('os')
if (os.platform() === 'win32' && os.release().startsWith('10.')) {
notifier.notify = function(options) {
var {title, message, icon} = options
export async function rollupBundleFile(opts: RollupOptions): Promise {
log.debug(`rollup (v${rollup.VERSION}) ${opts.entry} to ${opts.dest} (${opts.format})`);
const externalModuleIdStrategy = new ExternalModuleIdStrategy(opts.format, opts.dependencyList);
// Create the bundle
const bundle = await rollup.rollup({
context: 'this',
external: moduleId => externalModuleIdStrategy.isExternalDependency(moduleId),
inlineDynamicImports: false,
input: opts.entry,
plugins: [
rollupJson(),
// @ts-ignore
nodeResolve(),
// @ts-ignore
commonJs(),
sourcemaps(),
async function rollup(opts: RollupOptions): Promise {
log.debug(`rollup (v${__rollup.VERSION}) ${opts.entry} to ${opts.dest} (${opts.format})`);
// Create the bundle
const bundle: __rollup.Bundle = await __rollup.rollup({
context: 'this',
external: moduleId => externalModuleIdStrategy(moduleId, opts.embedded || []),
input: opts.entry,
plugins: [
nodeResolve({ jsnext: true, module: true }),
commonJs(),
],
onwarn: (warning) => {
if (warning.code === 'THIS_IS_UNDEFINED') {
return;
}
log.warn(warning.message);
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
'use strict';
const rollup = require('rollup');
const VERSION = rollup.VERSION || '0';
const MAJOR_VERSION = Number(VERSION.split('.')[0]) || 0;
const IS_ROLLUP_LEGACY = MAJOR_VERSION === 0;
module.exports = IS_ROLLUP_LEGACY ? require('./index-rollup-legacy.js') : require('./index-rollup-stable.js');
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
'use strict';
const rollup = require('rollup');
const VERSION = rollup.VERSION;
const MAJOR_VERSION = VERSION ? Number(VERSION.split('.')[0]) : 0;
const IS_ROLLUP_LEGACY = MAJOR_VERSION === 0;
module.exports = IS_ROLLUP_LEGACY ? require('./index-rollup-legacy') : require('./index-rollup-stable');