-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Upgrade dependencies #16
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"esversion": 6 | ||
} |
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/** | ||
This file contains black magic. Don't overthink it. | ||
|
||
In rollup configuration use it like this: | ||
|
||
const extensions = require("./extensions") | ||
rollup({ | ||
plugins: [ | ||
extensions({ | ||
extensions: [".jsx", ".foobar", ".etc"] | ||
}), | ||
] | ||
}); | ||
|
||
Most of this file's code was taken from here: https://github.com/rollup/rollup/issues/1052 | ||
*/ | ||
|
||
const { basename, dirname, isAbsolute, resolve } = require("path"); | ||
const fs = require("fs"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). |
||
|
||
function isFile(file) { | ||
try { | ||
return fs.statSync(file).isFile(); | ||
} catch (err) { | ||
return false; | ||
} | ||
} | ||
|
||
function addExtensionIfNecessary(file, extensions) { | ||
try { | ||
const name = basename(file); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). |
||
const files = fs.readdirSync(dirname(file)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). |
||
|
||
if (~files.indexOf(name) && isFile(file)) return file; | ||
for (const ext of extensions) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'for of' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). |
||
if (~files.indexOf(`${name}${ext}`) && isFile(`${file}${ext}`)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'template literal syntax' is only available in ES6 (use 'esversion: 6'). |
||
return `${file}${ext}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'template literal syntax' is only available in ES6 (use 'esversion: 6'). |
||
} | ||
|
||
// In case `file` is a folder name, we check if there is an | ||
// index file in the folder | ||
const indexPath = `${file}/index${ext}`; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). |
||
if (isFile(indexPath)) { | ||
return indexPath; | ||
} | ||
} | ||
} catch (err) { | ||
// noop | ||
} | ||
|
||
return null; | ||
} | ||
|
||
module.exports = function extensions({ extensions }) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'destructuring binding' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). |
||
if (!extensions || !extensions.length) { | ||
throw new Error( | ||
`Must specify { extensions: [..] } as non-empty array!` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'template literal syntax' is only available in ES6 (use 'esversion: 6'). |
||
); | ||
} | ||
|
||
return { | ||
name: "extensions", | ||
|
||
resolveId(importee, importer) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'concise methods' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). |
||
// absolute paths are left untouched | ||
if (isAbsolute(importee)) { | ||
return addExtensionIfNecessary(resolve(importee), extensions); | ||
} | ||
|
||
// if this is the entry point, resolve against cwd | ||
if (importer === undefined) { | ||
return addExtensionIfNecessary( | ||
resolve(process.cwd(), importee), | ||
extensions | ||
); | ||
} | ||
|
||
// external modules are skipped at this stage | ||
if (importee[0] !== ".") return null; | ||
|
||
return addExtensionIfNecessary( | ||
resolve(dirname(importer), importee), | ||
extensions | ||
); | ||
} | ||
}; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ const nodeResolve = require('rollup-plugin-node-resolve'); | |
const organiser = require('gulp-organiser'); | ||
const { curry } = require('lodash/fp'); | ||
const rename = require("gulp-rename"); | ||
const extensions = require("./extensions"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz). |
||
|
||
const DEFAULT_CONFIG = { | ||
sourceMap: true, | ||
|
@@ -35,8 +36,10 @@ const DEFAULT_CONFIG = { | |
// Let's use AMD format to serve our files to the front-end | ||
format: 'umd', | ||
plugins: [ | ||
// Reslver to allow importing .jsx files | ||
extensions({ extensions: [".jsx", ".js"] }), | ||
// Import modules with jsnext:main | ||
nodeResolve({ jsnext: true, main: true }), | ||
nodeResolve({ jsnext: true, main: true }), | ||
// Allow importing commonjs modules | ||
commonjs(), | ||
// Transpile our code to ES5 | ||
|
@@ -53,7 +56,7 @@ const DEFAULT_CONFIG = { | |
"regenerator": true | ||
}] | ||
], | ||
presets: ['es2015-rollup', 'react'], | ||
presets: [['env', { targets: { 'ie': 8 }, modules: false }], 'react'], | ||
}), | ||
// TODO: Change this from 'development' to 'production' during production | ||
replace({ 'process.env.NODE_ENV': JSON.stringify('production') }), | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'const' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).
'destructuring binding' is available in ES6 (use 'esversion: 6') or Mozilla JS extensions (use moz).