Fix Flarum on iOS 10 and below (#9)

* Ignore .vscode folder

* Add Prettier config

* Change author to 'Flarum Team'

* Bump deps to latest version

* Format with prettier; add `loose` where needed

* Don't exclude node modules from Babel processing
This commit is contained in:
David Wheatley 2021-05-04 00:39:10 +01:00 committed by GitHub
parent a6cc7d3742
commit 8c2642b2f2
5 changed files with 10392 additions and 730 deletions

View File

@ -1,3 +1,4 @@
node_modules
.DS_Store
Thumbs.db
.vscode

View File

@ -0,0 +1,6 @@
{
"printWidth": 150,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "es5"
}

View File

@ -2,85 +2,89 @@ const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
module.exports = function(options = {}) {
module.exports = function (options = {}) {
return {
// Set up entry points for each of the forum + admin apps, but only
// if they exist.
entry: function() {
entry: (function () {
const entries = {};
for (const app of ['forum', 'admin']) {
const file = path.resolve(process.cwd(), app+'.js');
const file = path.resolve(process.cwd(), app + '.js');
if (fs.existsSync(file)) {
entries[app] = file;
}
}
return entries;
}(),
})(),
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: {
loader: 'babel-loader',
options: {
presets: [
['@babel/preset-env', {modules: false, loose: true}],
['@babel/preset-react']
[
'@babel/preset-env',
{
modules: false,
loose: true,
},
],
['@babel/preset-react'],
],
plugins: [
['@babel/plugin-transform-runtime', {useESModules: true}],
['@babel/plugin-proposal-class-properties'],
['@babel/plugin-transform-react-jsx', {pragma: 'm'}],
['@babel/plugin-transform-object-assign']
]
}
}
}
]
['@babel/plugin-transform-runtime', { useESModules: true }],
['@babel/plugin-proposal-class-properties', { loose: true }],
['@babel/plugin-proposal-private-methods', { loose: true }],
['@babel/plugin-transform-react-jsx', { pragma: 'm' }],
],
},
},
},
],
},
output: {
path: path.resolve(process.cwd(), 'dist'),
library: 'module.exports',
libraryTarget: 'assign',
devtoolNamespace: require(path.resolve(process.cwd(), 'package.json')).name
devtoolNamespace: require(path.resolve(process.cwd(), 'package.json')).name,
},
externals: [
{
'@flarum/core/forum': 'flarum.core',
'@flarum/core/admin': 'flarum.core',
'jquery': 'jQuery',
jquery: 'jQuery',
},
function() {
(function () {
const externals = {};
if (options.useExtensions) {
for (const extension of options.useExtensions) {
externals['@'+extension] =
externals['@'+extension+'/forum'] =
externals['@'+extension+'/admin'] = "flarum.extensions['"+extension+"']";
externals['@' + extension] = externals['@' + extension + '/forum'] = externals['@' + extension + '/admin'] =
"flarum.extensions['" + extension + "']";
}
}
return externals;
}(),
})(),
// Support importing old-style core modules.
function(context, request, callback) {
function (context, request, callback) {
let matches;
if ((matches = /^flarum\/(.+)$/.exec(request))) {
return callback(null, 'root flarum.core.compat[\'' + matches[1] + '\']');
return callback(null, "root flarum.core.compat['" + matches[1] + "']");
}
callback();
}
},
],
devtool: 'source-map'
devtool: 'source-map',
};
};

File diff suppressed because it is too large Load Diff

View File

@ -3,20 +3,24 @@
"version": "0.1.0-beta.10",
"description": "Webpack config for Flarum JavaScript compilation.",
"main": "index.js",
"author": "Toby Zerner",
"author": "Flarum Team",
"license": "MIT",
"peerDependencies": {
"webpack": "^4.0.0"
},
"dependencies": {
"@babel/core": "^7.0.0",
"@babel/plugin-proposal-class-properties": "^7.0.0",
"@babel/plugin-transform-object-assign": "^7.0.0",
"@babel/plugin-transform-react-jsx": "^7.0.0",
"@babel/plugin-transform-runtime": "^7.0.0",
"@babel/preset-env": "^7.0.0",
"@babel/preset-react": "^7.0.0",
"@babel/runtime": "^7.0.0",
"babel-loader": "^8.0.0"
"@babel/core": "^7.14.0",
"@babel/plugin-proposal-class-properties": "^7.13.0",
"@babel/plugin-proposal-private-methods": "^7.13.0",
"@babel/plugin-transform-object-assign": "^7.12.13",
"@babel/plugin-transform-react-jsx": "^7.13.12",
"@babel/plugin-transform-runtime": "^7.13.15",
"@babel/preset-env": "^7.14.0",
"@babel/preset-react": "^7.13.13",
"@babel/runtime": "^7.14.0",
"babel-loader": "^8.2.2"
},
"devDependencies": {
"prettier": "^2.2.1"
}
}