Commit Graph

29 Commits

Author SHA1 Message Date
David Wheatley
3537f76eab
Update core to use new Webpack config, flarum-tsconfig, and build action (#2856)
* Update core to use new Webpack and TSConfig

* Bump webpack dep

* Update JS build action

* Copy custom `.d.ts` files to `dist-typings` folder on typings compile

* Run workflow against action v2

This allows us to have a moving tag, like first party actions have.

* Remove bundle analyzer from core

* Use webpack config 0.1.0-beta.16.2

* Add note about checking flarum-tsconfig
2021-05-13 00:28:17 +01:00
David Wheatley
ceb567779e
Remove spin.js, bump some dependencies (#2848) 2021-05-09 18:09:29 -04:00
David Wheatley
da5db714c2
Remove lodash from core (#2827)
* Remove `lodash-es` dependency

* Replace `escapeRegExp` with home-made util

* Replace `throttle` with `throttle-debounce` library

* Use native browser methods for `deepFlatten`

We need a polyfill for iOS 11 and below. I think using a native method with this polyfill is better than having our own function instead, even if the bundle size is ~150B more.

* Save a few bytes in `escapeRegExp`

* Fix typo in comment

* Undo import re-organisation

* Use spread instead of slice

* Use smaller Array.flat polyfill from MDN

* Export new utils in `compat.js`
2021-05-06 00:28:22 +01:00
Alexander Skvortsov
b45519974a
Switch to ICU MessageFormat (#2759) 2021-04-30 12:44:39 -04:00
David Wheatley
e52b769ceb
Add option to build with Webpack Bundle Analyzer (#2708)
* Add option to build with webpack bundle analyzer

* Bump npm to v7 as recommended in actions/setup-node#213

* Workaround for npm/cli#558

* Add missing dep
2021-04-10 15:00:48 +01:00
David Wheatley
c75db75efe
Bump dependencies, add missing typing libraries (#2753)
* Bump dependencies and add missing typing libraries

* Fix expose-loader breaking changes

* Expose jQuery using its own typings instead of ours

* Extend jQuery typings with our own custom $.fn helpers

* Use jQuery typings for Component's `this.$` attribute

* Format webpack config file

* Use Spin.js 3.1.0
2021-04-08 12:35:10 +01:00
David Wheatley
4b69a35260
Replace classList with clsx library (#2760) 2021-04-05 16:27:16 +01:00
David Wheatley
298f6c39f2
Add bundlewatch to track bundle size changes in PRs (#2695)
(Below steps already performed, but kept for future reference.)

Head here to get auth ID: https://service.bundlewatch.io/setup-github
Create repo secret called `BUNDLEWATCH_GITHUB_TOKEN` with the token inside
2021-03-17 14:54:42 +00:00
Alexander Skvortsov
7d79912d36
Editor Driver Abstraction (#2594)
This will allow drop-in replacements of the editor with a more advanced WYSIWYG solution such as ProseMirror
2021-02-26 16:17:05 -05:00
Alexander Skvortsov
fae79ea910 Bring m.attrs.bidi in as a util
We previously used the tobscure/m.attrs.bidi github repo, but that repo was recently taken offline. We decided to integrate it as a util instead of publishing it as a separate package since we seem to be the only project using it, and adopting it into a new project requires barneycarroll/mattr, which does not seem to be used anywhere.

The code added here was taken from https://github.com/askvortsov1/m.attrs.bidi, a fork (without changes) of the tobscure repo. Support for alternative module systems and ways of registering bidi were removed, and the file was formatted in compliance with our prettier config.
2021-01-19 17:30:03 -05:00
Daniël Klabbers
6da81a71a4 npm audit security vulnerabilities patched 2020-10-14 10:11:34 +02:00
David Sevilla Martín
71f3379fcc
Mithril 2 update (#2255)
* Update frontend to Mithril 2

- Update Mithril version to v2.0.4
- Add Typescript typings for Mithril
- Rename "props" to "attrs"; "initProps" to "initAttrs"; "m.prop" to "m.stream"; "m.withAttr" to "utils/withAttr".
- Use Mithril 2's new lifecycle hooks
- SubtreeRetainer has been rewritten to be more useful for the new system
- Utils for forcing page re-initializations have been added (force attr in links, setRouteWithForcedRefresh util)
- Other mechanical changes, following the upgrade guide
- Remove some of the custom stuff in our Component base class
- Introduce "fragments" for non-components that control their own DOM
- Remove Mithril patches, introduce a few new ones (route attrs in <a>; 
- Redesign AlertManagerState `show` with 3 overloads: `show(children)`, `show(attrs, children)`, `show(componentClass, attrs, children)`
- The `affixedSidebar` util has been replaced with an `AffixedSidebar` component

Challenges:
- `children` and `tag` are now reserved, and can not be used as attr names
- Behavior of links to current page changed in Mithril. If moving to a page that is handled by the same component, the page component WILL NOT be re-initialized by default. Additional code to keep track of the current url is needed (See IndexPage, DiscussionPage, and UserPage for examples)
- Native Promise rejections are shown on console when not handled
- Instances of components can no longer be stored. The state pattern should be used instead.

Refs #1821.

Co-authored-by: Alexander Skvortsov <sasha.skvortsov109@gmail.com>
Co-authored-by: Matthew Kilgore <tankerkiller125@gmail.com>
Co-authored-by: Franz Liedke <franz@develophp.org>
2020-09-23 22:40:37 -04:00
David Sevilla Martín
d189272473
Initial TypeScript infrastructure (#2206)
This allows us to get started with converting all Flarum JavaScript code to TypeScript.
In addition, we will have time to experiment to find the best Webpack configuration before integrating into flarum-webpack-config.

See flarum/flarum-webpack-config#3.
2020-07-03 14:47:44 +02:00
David Sevilla Martín
8dd5420405
Switch from 'moment' to 'dayjs' (#2219)
* Switch from 'moment' to 'dayjs'

* Use humanize code from duration plugin (without actual plugin) for time lapsed events
2020-06-30 20:33:00 -04:00
Franz Liedke
526081bd06
Update Webpack 2020-05-01 11:52:26 +02:00
Franz Liedke
899cdfda4e
CI: Run prettier to check for JS code formatting 2020-04-17 11:14:37 +02:00
Franz Liedke
72ed4faa83
Setup husky for automatic formatting before commit 2020-04-17 10:45:36 +02:00
Franz Liedke
64ad21e5da
Add NPM shortcut for running prettier 2020-04-17 10:45:05 +02:00
Franz Liedke
ee996e2cae
Install prettier 2020-04-17 10:44:31 +02:00
Franz Liedke
c1878fe29b
Update Webpack 2019-12-10 15:38:56 +01:00
dependabot[bot]
d2700961ba Bump lodash-es from 4.17.11 to 4.17.14 in /js (#1818)
Bumps [lodash-es](https://github.com/lodash/lodash) from 4.17.11 to 4.17.14.
- [Release notes](https://github.com/lodash/lodash/releases)
- [Commits](https://github.com/lodash/lodash/compare/4.17.11...4.17.14)

Signed-off-by: dependabot[bot] <support@github.com>
2019-07-11 09:21:17 +02:00
Franz Liedke
24522943f6
Update insecure jQuery version
Thanks, GitHub security alerts!
2019-06-01 20:03:07 +02:00
Franz Liedke
d959d08561
NPM: Update bootstrap package
The old version had a vulnerability.

See https://nvd.nist.gov/vuln/detail/CVE-2019-8331.
2019-03-03 20:27:14 +01:00
Toby Zerner
b074f47298 Fix build errors by updating webpack-cli 2018-11-22 08:04:08 +10:30
Toby Zerner
c11e4720d9 Change watch command to dev 2018-11-21 18:31:54 +10:30
Toby Zerner
c73d03a427 Make npm package private, update deps 2018-11-21 18:31:24 +10:30
Toby Zerner
710c63ba6a Update JS tooling 2018-08-25 20:18:59 +09:30
Toby Zerner
805768a9e0
[WIP] JS Extender API foundation (#1468)
* Run extenders exported by extensions
* Add some basic extenders
* Patch Mithril as the very first thing so extension code can run safely
* Load the payload into the app before booting extensions
* Setup default routes before booting extensions
2018-06-22 10:49:46 +09:30
Toby Zerner
3f683dd6ee
Webpack (#1367)
* Replace gulp with webpack and npm scripts for JS compilation
* Set up Travis CI to commit compiled JS
* Restructure `js` directory; only one instance of npm, forum/admin are "submodules"
* Refactor JS initializers into Application subclasses
* Maintain partial compatibility API (importing from absolute paths) for extensions
* Remove minification responsibility from PHP asset compiler
* Restructure `less` directory
2018-06-20 13:20:31 +09:30