0
0
Fork 0

Dont use CommonJS (require, module.exports) anywhere (#24913)

This commit is contained in:
Renaud Chaput 2023-05-09 03:08:47 +02:00 committed by GitHub
parent 89269e4b71
commit 955179fc55
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 79 additions and 41 deletions

View file

@ -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);
}