Merge pull request #499 from mozilla/pier1

use import/export in the frontend code
This commit is contained in:
Danny Coates 2017-08-10 11:07:38 -07:00 committed by GitHub
commit ec80e8e622
15 changed files with 51 additions and 64 deletions

View File

@ -1,3 +1,9 @@
env: env:
browser: true browser: true
jquery: true node: false
parserOptions:
sourceType: module
rules:
node/no-unsupported-features: off

View File

@ -1,5 +1,5 @@
const Raven = require('raven-js'); import Raven from 'raven-js';
const { unsupported } = require('./metrics'); import { unsupported } from './metrics';
if (navigator.doNotTrack !== '1' && window.RAVEN_CONFIG) { if (navigator.doNotTrack !== '1' && window.RAVEN_CONFIG) {
Raven.config(window.SENTRY_ID, window.RAVEN_CONFIG).install(); Raven.config(window.SENTRY_ID, window.RAVEN_CONFIG).install();
@ -17,6 +17,4 @@ if (
}); });
} }
module.exports = { export { Raven };
Raven
};

View File

@ -1,13 +1,13 @@
const { Raven } = require('./common'); import { Raven } from './common';
const FileReceiver = require('./fileReceiver'); import FileReceiver from './fileReceiver';
const { bytes, notify, gcmCompliant } = require('./utils'); import { bytes, notify, gcmCompliant } from './utils';
const Storage = require('./storage'); import Storage from './storage';
const storage = new Storage(); import * as links from './links';
const links = require('./links'); import * as metrics from './metrics';
const metrics = require('./metrics'); import * as progress from './progress';
const progress = require('./progress'); import $ from 'jquery';
const $ = require('jquery');
const storage = new Storage(localStorage);
function onUnload(size) { function onUnload(size) {
metrics.cancelledDownload({ size }); metrics.cancelledDownload({ size });
} }

View File

@ -1,7 +1,7 @@
const EventEmitter = require('events'); import EventEmitter from 'events';
const { hexToArray } = require('./utils'); import { hexToArray } from './utils';
class FileReceiver extends EventEmitter { export default class FileReceiver extends EventEmitter {
constructor() { constructor() {
super(); super();
} }
@ -86,5 +86,3 @@ class FileReceiver extends EventEmitter {
}); });
} }
} }
module.exports = FileReceiver;

View File

@ -1,7 +1,7 @@
const EventEmitter = require('events'); import EventEmitter from 'events';
const { arrayToHex } = require('./utils'); import { arrayToHex } from './utils';
class FileSender extends EventEmitter { export default class FileSender extends EventEmitter {
constructor(file) { constructor(file) {
super(); super();
this.file = file; this.file = file;
@ -116,5 +116,3 @@ class FileSender extends EventEmitter {
}); });
} }
} }
module.exports = FileSender;

View File

@ -18,6 +18,4 @@ function setOpenInNewTab(bool) {
} }
} }
module.exports = { export { setOpenInNewTab };
setOpenInNewTab
};

View File

@ -1,5 +1,5 @@
const testPilotGA = require('testpilot-ga/src/TestPilotGA'); import testPilotGA from 'testpilot-ga/src/TestPilotGA';
const Storage = require('./storage'); import Storage from './storage';
const storage = new Storage(); const storage = new Storage();
let hasLocalStorage = false; let hasLocalStorage = false;
@ -234,7 +234,7 @@ function addRestartHandlers() {
}); });
} }
module.exports = { export {
copiedLink, copiedLink,
startedUpload, startedUpload,
cancelledUpload, cancelledUpload,

View File

@ -1,6 +1,6 @@
const { bytes, percent } = require('./utils'); import { bytes, percent } from './utils';
const $ = require('jquery'); import $ from 'jquery';
require('jquery-circle-progress'); import 'jquery-circle-progress';
let $progress = null; let $progress = null;
let $percent = null; let $percent = null;
@ -50,7 +50,4 @@ function setText(str) {
$text.text(str); $text.text(str);
} }
module.exports = { export { setProgress, setText };
setProgress,
setText
};

View File

@ -1,4 +1,4 @@
const { isFile } = require('./utils'); import { isFile } from './utils';
class Mem { class Mem {
constructor() { constructor() {
@ -26,7 +26,7 @@ class Mem {
} }
} }
class Storage { export default class Storage {
constructor() { constructor() {
try { try {
this.engine = localStorage || new Mem(); this.engine = localStorage || new Mem();
@ -97,5 +97,3 @@ class Storage {
this.engine.setItem(id, JSON.stringify(file)); this.engine.setItem(id, JSON.stringify(file));
} }
} }
module.exports = Storage;

View File

@ -1,19 +1,19 @@
/* global MAXFILESIZE EXPIRE_SECONDS */ /* global MAXFILESIZE EXPIRE_SECONDS */
const { Raven } = require('./common'); import { Raven } from './common';
const FileSender = require('./fileSender'); import FileSender from './fileSender';
const { import {
bytes, bytes,
copyToClipboard, copyToClipboard,
notify, notify,
gcmCompliant, gcmCompliant,
ONE_DAY_IN_MS ONE_DAY_IN_MS
} = require('./utils'); } from './utils';
const Storage = require('./storage'); import Storage from './storage';
const storage = new Storage(); import * as metrics from './metrics';
const metrics = require('./metrics'); import * as progress from './progress';
const progress = require('./progress'); import $ from 'jquery';
const $ = require('jquery'); const storage = new Storage(localStorage);
const allowedCopy = () => { const allowedCopy = () => {
const support = !!document.queryCommandSupported; const support = !!document.queryCommandSupported;

View File

@ -131,7 +131,7 @@ function percent(ratio) {
const ONE_DAY_IN_MS = 86400000; const ONE_DAY_IN_MS = 86400000;
module.exports = { export {
bytes, bytes,
percent, percent,
copyToClipboard, copyToClipboard,

6
package-lock.json generated
View File

@ -551,12 +551,6 @@
"babel-runtime": "6.25.0" "babel-runtime": "6.25.0"
} }
}, },
"babel-plugin-add-module-exports": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/babel-plugin-add-module-exports/-/babel-plugin-add-module-exports-0.2.1.tgz",
"integrity": "sha1-mumh9KjcZ/DN7E9K7aHkOl/2XiU=",
"dev": true
},
"babel-plugin-check-es2015-constants": { "babel-plugin-check-es2015-constants": {
"version": "6.22.0", "version": "6.22.0",
"resolved": "https://registry.npmjs.org/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz", "resolved": "https://registry.npmjs.org/babel-plugin-check-es2015-constants/-/babel-plugin-check-es2015-constants-6.22.0.tgz",

View File

@ -20,7 +20,6 @@
"autoprefixer": "^7.1.2", "autoprefixer": "^7.1.2",
"babel-core": "^6.25.0", "babel-core": "^6.25.0",
"babel-loader": "^7.1.1", "babel-loader": "^7.1.1",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-polyfill": "^6.23.0", "babel-polyfill": "^6.23.0",
"babel-preset-es2015": "^6.24.1", "babel-preset-es2015": "^6.24.1",
"babel-preset-stage-2": "^6.24.1", "babel-preset-stage-2": "^6.24.1",

View File

@ -44,9 +44,11 @@ if (conf.env === 'development') {
const config = require('../webpack.config.js'); const config = require('../webpack.config.js');
config.devtool = 'inline-source-map'; config.devtool = 'inline-source-map';
const compiler = webpack(config); const compiler = webpack(config);
app.use(webpackDevMiddleware(compiler, { app.use(
webpackDevMiddleware(compiler, {
publicPath: config.output.publicPath publicPath: config.output.publicPath
})); })
);
} }
app.engine( app.engine(

View File

@ -21,8 +21,7 @@ module.exports = {
], ],
query: { query: {
babelrc: false, babelrc: false,
presets: ['es2015', 'stage-2'], presets: [['es2015', { modules: false }], 'stage-2']
plugins: ['add-module-exports']
} }
} }
] ]