1
0
Эх сурвалжийг харах

replace `module.exports` with `export default`; separate js and css files into different folder

DIYgod 7 жил өмнө
parent
commit
100234774d

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "dplayer",
-  "version": "1.17.4",
+  "version": "1.17.5",
   "description": "Wow, such a lovely HTML5 danmaku video player",
   "main": "dist/DPlayer.min.js",
   "style": "dist/DPlayer.min.css",

+ 1 - 1
src/DPlayer.scss → src/css/index.scss

@@ -1,4 +1,4 @@
-@import '../node_modules/balloon-css/balloon.css';
+@import '../../node_modules/balloon-css/balloon.css';
 
 .dplayer {
     position: relative;

+ 1 - 3
src/DPlayer.js → src/js/DPlayer.js

@@ -1,5 +1,3 @@
-import './DPlayer.scss';
-
 import utils, { isMobile } from './utils';
 import handleOption from './options';
 import i18n from './i18n';
@@ -497,4 +495,4 @@ class DPlayer {
     }
 }
 
-module.exports = DPlayer;
+export default DPlayer;

+ 1 - 1
src/api.js → src/js/api.js

@@ -27,7 +27,7 @@ const SendXMLHttpRequest = (url, data, success, error, fail) => {
     xhr.send(data !== null ? JSON.stringify(data) : null);
 };
 
-module.exports = {
+export default {
     send: (endpoint, danmakuData, callback) => {
         SendXMLHttpRequest(endpoint, danmakuData, (xhr, response) => {
             console.log('Post danmaku: ', response);

+ 1 - 1
src/bar.js → src/js/bar.js

@@ -25,4 +25,4 @@ class Bar {
     }
 }
 
-module.exports = Bar;
+export default Bar;

+ 1 - 1
src/bezel.js → src/js/bezel.js

@@ -13,4 +13,4 @@ class Bezel {
     }
 }
 
-module.exports = Bezel;
+export default Bezel;

+ 1 - 1
src/comment.js → src/js/comment.js

@@ -90,4 +90,4 @@ class Comment {
     }
 }
 
-module.exports = Comment;
+export default Comment;

+ 1 - 1
src/contextmenu.js → src/js/contextmenu.js

@@ -49,4 +49,4 @@ class ContextMenu {
     }
 }
 
-module.exports = ContextMenu;
+export default ContextMenu;

+ 1 - 1
src/controller.js → src/js/controller.js

@@ -251,4 +251,4 @@ class Controller {
     }
 }
 
-module.exports = Controller;
+export default Controller;

+ 1 - 1
src/danmaku.js → src/js/danmaku.js

@@ -340,4 +340,4 @@ class Danmaku {
     }
 }
 
-module.exports = Danmaku;
+export default Danmaku;

+ 1 - 1
src/events.js → src/js/events.js

@@ -53,4 +53,4 @@ class Events {
     }
 }
 
-module.exports = Events;
+export default Events;

+ 1 - 1
src/fullscreen.js → src/js/fullscreen.js

@@ -101,4 +101,4 @@ class FullScreen {
     }
 }
 
-module.exports = FullScreen;
+export default FullScreen;

+ 1 - 1
src/hotkey.js → src/js/hotkey.js

@@ -52,4 +52,4 @@ class HotKey {
     }
 }
 
-module.exports = HotKey;
+export default HotKey;

+ 5 - 3
src/i18n.js → src/js/i18n.js

@@ -7,7 +7,7 @@ W3C def language codes is :
 NOTE: use lowercase to prevent case typo from user!
 Use this as shown below..... */
 
-module.exports = function (lang) {
+function i18n (lang) {
     this.lang = lang;
     this.tran = (text) => {
         if (tranTxt[this.lang] && tranTxt[this.lang][text]) {
@@ -17,7 +17,7 @@ module.exports = function (lang) {
             return text;
         }
     };
-};
+}
 
 // add translation text here
 const tranTxt = {
@@ -93,4 +93,6 @@ const tranTxt = {
         'Volume': '音量',
         'Live': '直播',
     }
-};
+};
+
+export default i18n;

+ 4 - 1
src/index.js → src/js/index.js

@@ -1,4 +1,7 @@
+import '../css/index.scss';
+import DPlayer from './DPlayer';
+
 /* global DPLAYER_VERSION GIT_HASH */
 console.log(`${'\n'} %c DPlayer ${DPLAYER_VERSION} ${GIT_HASH} %c http://dplayer.js.org ${'\n'}${'\n'}`, 'color: #fadfa3; background: #030307; padding:5px 0;', 'background: #fadfa3; padding:5px 0;');
 
-module.exports = require('./DPlayer');
+export default DPlayer;

+ 2 - 2
src/options.js → src/js/options.js

@@ -1,7 +1,7 @@
 /* global DPLAYER_VERSION GIT_HASH */
-const defaultApiBackend = require('./api.js');
+import defaultApiBackend from './api.js';
 
-module.exports = (options) => {
+export default (options) => {
     const isMobile = /mobile/i.test(window.navigator.userAgent);
     // compatibility: some mobile browsers don't suppose autoplay
     if (isMobile) {

+ 1 - 1
src/setting.js → src/js/setting.js

@@ -130,4 +130,4 @@ class Setting {
     }
 }
 
-module.exports = Setting;
+export default Setting;

+ 1 - 1
src/subtitle.js → src/js/subtitle.js

@@ -52,4 +52,4 @@ class Subtitle {
     }
 }
 
-module.exports = Subtitle;
+export default Subtitle;

+ 1 - 1
src/svg.js → src/js/svg.js

@@ -21,4 +21,4 @@ class SvgSource {
     }
 }
 
-module.exports = SvgSource;
+export default SvgSource;

+ 1 - 1
src/template.js → src/js/template.js

@@ -341,4 +341,4 @@ class Template {
     }
 }
 
-module.exports = Template;
+export default Template;

+ 1 - 1
src/thumbnails.js → src/js/thumbnails.js

@@ -29,4 +29,4 @@ class Thumbnails {
     }
 }
 
-module.exports = Thumbnails;
+export default Thumbnails;

+ 1 - 1
src/time.js → src/js/time.js

@@ -100,4 +100,4 @@ class Time {
     }
 }
 
-module.exports = Time;
+export default Time;

+ 1 - 1
src/user.js → src/js/user.js

@@ -38,4 +38,4 @@ class User {
     }
 }
 
-module.exports = User;
+export default User;

+ 1 - 1
src/utils.js → src/js/utils.js

@@ -1,4 +1,4 @@
-module.exports = {
+export default {
 
     /**
     * Parse second to 00:00 format

+ 3 - 2
webpack/dev.config.js

@@ -9,7 +9,7 @@ module.exports = {
     devtool: 'cheap-module-source-map',
 
     entry: {
-        'DPlayer': './src/index.js'
+        'DPlayer': './src/js/index.js'
     },
 
     output: {
@@ -17,6 +17,7 @@ module.exports = {
         filename: '[name].js',
         library: '[name]',
         libraryTarget: 'umd',
+        libraryExport: 'default',
         umdNamedDefine: true,
         publicPath: '/'
     },
@@ -33,7 +34,7 @@ module.exports = {
                 test: /\.js$/,
                 enforce: 'pre',
                 loader: require.resolve('eslint-loader'),
-                include: path.resolve(__dirname, '../src'),
+                include: path.resolve(__dirname, '../src/js'),
             },
             {
                 test: /\.js$/,

+ 3 - 2
webpack/prod.config.js

@@ -12,7 +12,7 @@ module.exports = {
     devtool: 'source-map',
 
     entry: {
-        'DPlayer': './src/index.js'
+        'DPlayer': './src/js/index.js'
     },
 
     output: {
@@ -20,6 +20,7 @@ module.exports = {
         filename: '[name].min.js',
         library: '[name]',
         libraryTarget: 'umd',
+        libraryExport: 'default',
         umdNamedDefine: true,
         publicPath: '/'
     },
@@ -36,7 +37,7 @@ module.exports = {
                 test: /\.js$/,
                 enforce: 'pre',
                 loader: require.resolve('eslint-loader'),
-                include: path.resolve(__dirname, '../src'),
+                include: path.resolve(__dirname, '../src/js'),
             },
             {
                 test: /\.js$/,