Dont use CommonJS (require
, module.exports
) anywhere (#24913)
This commit is contained in:
parent
89269e4b71
commit
955179fc55
17 changed files with 79 additions and 41 deletions
|
@ -1,6 +1,8 @@
|
|||
import './public-path';
|
||||
import { delegate } from '@rails/ujs';
|
||||
import ready from '../mastodon/ready';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
const setAnnouncementEndsAttributes = (target) => {
|
||||
const valid = target?.value && target?.validity?.valid;
|
||||
|
@ -223,9 +225,6 @@ ready(() => {
|
|||
setAnnouncementEndsAttributes(announcementStartsAt);
|
||||
}
|
||||
|
||||
const React = require('react');
|
||||
const ReactDOM = require('react-dom');
|
||||
|
||||
[].forEach.call(document.querySelectorAll('[data-admin-component]'), element => {
|
||||
const componentName = element.getAttribute('data-admin-component');
|
||||
const { locale, ...componentProps } = JSON.parse(element.getAttribute('data-props'));
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
require('../styles/mailer.scss');
|
||||
import '../styles/mailer.scss';
|
||||
|
||||
require.context('../icons');
|
||||
|
|
|
@ -1,13 +1,24 @@
|
|||
import './public-path';
|
||||
import escapeTextContentForBrowser from 'escape-html';
|
||||
import loadPolyfills from '../mastodon/load_polyfills';
|
||||
import ready from '../mastodon/ready';
|
||||
import { start } from '../mastodon/common';
|
||||
|
||||
import escapeTextContentForBrowser from 'escape-html';
|
||||
import ready from '../mastodon/ready';
|
||||
import loadKeyboardExtensions from '../mastodon/load_keyboard_extensions';
|
||||
import 'cocoon-js-vanilla';
|
||||
import axios from 'axios';
|
||||
import { throttle } from 'lodash';
|
||||
import { defineMessages } from 'react-intl';
|
||||
import * as IntlMessageFormat from 'intl-messageformat';
|
||||
import { timeAgoString } from '../mastodon/components/relative_timestamp';
|
||||
import { delegate } from '@rails/ujs';
|
||||
import * as emojify from '../mastodon/features/emoji/emoji';
|
||||
import { getLocale } from '../mastodon/locales';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
import { createBrowserHistory } from 'history';
|
||||
|
||||
start();
|
||||
|
||||
const messages = defineMessages({
|
||||
usernameTaken: { id: 'username.taken', defaultMessage: 'That username is taken. Try another' },
|
||||
|
@ -15,8 +26,6 @@ const messages = defineMessages({
|
|||
passwordDoesNotMatch: { id: 'password_confirmation.mismatching', defaultMessage: 'Password confirmation does not match' },
|
||||
});
|
||||
|
||||
start();
|
||||
|
||||
window.addEventListener('message', e => {
|
||||
const data = e.data || {};
|
||||
|
||||
|
@ -33,16 +42,8 @@ window.addEventListener('message', e => {
|
|||
});
|
||||
});
|
||||
|
||||
function main() {
|
||||
const IntlMessageFormat = require('intl-messageformat').default;
|
||||
const { timeAgoString } = require('../mastodon/components/relative_timestamp');
|
||||
const { delegate } = require('@rails/ujs');
|
||||
const emojify = require('../mastodon/features/emoji/emoji').default;
|
||||
const { getLocale } = require('../mastodon/locales');
|
||||
function loaded() {
|
||||
const { localeData } = getLocale();
|
||||
const React = require('react');
|
||||
const ReactDOM = require('react-dom');
|
||||
const { createBrowserHistory } = require('history');
|
||||
|
||||
const scrollToDetailedStatus = () => {
|
||||
const history = createBrowserHistory();
|
||||
|
@ -341,6 +342,11 @@ function main() {
|
|||
});
|
||||
}
|
||||
|
||||
|
||||
function main() {
|
||||
ready(loaded);
|
||||
}
|
||||
|
||||
loadPolyfills()
|
||||
.then(main)
|
||||
.then(loadKeyboardExtensions)
|
||||
|
|
|
@ -1,23 +1,26 @@
|
|||
import './public-path';
|
||||
import loadPolyfills from '../mastodon/load_polyfills';
|
||||
import { start } from '../mastodon/common';
|
||||
import ready from '../mastodon/ready';
|
||||
import ComposeContainer from '../mastodon/containers/compose_container';
|
||||
import React from 'react';
|
||||
import ReactDOM from 'react-dom';
|
||||
|
||||
start();
|
||||
|
||||
function loaded() {
|
||||
const ComposeContainer = require('../mastodon/containers/compose_container').default;
|
||||
const React = require('react');
|
||||
const ReactDOM = require('react-dom');
|
||||
const mountNode = document.getElementById('mastodon-compose');
|
||||
|
||||
if (mountNode !== null) {
|
||||
const props = JSON.parse(mountNode.getAttribute('data-props'));
|
||||
if (mountNode) {
|
||||
const attr = mountNode.getAttribute('data-props');
|
||||
if(!attr) return;
|
||||
|
||||
const props = JSON.parse(attr);
|
||||
ReactDOM.render(<ComposeContainer {...props} />, mountNode);
|
||||
}
|
||||
}
|
||||
|
||||
function main() {
|
||||
const ready = require('../mastodon/ready').default;
|
||||
ready(loaded);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue