Convert application entrypoint files into Typescript
This commit is contained in:
parent
4efdcc3b14
commit
7882bbf98f
|
@ -1,5 +1,6 @@
|
||||||
import loadPolyfills from './soapbox/load_polyfills';
|
import loadPolyfills from './soapbox/load_polyfills';
|
||||||
|
|
||||||
|
// @ts-ignore
|
||||||
require.context('./images/', true);
|
require.context('./images/', true);
|
||||||
|
|
||||||
// Load stylesheet
|
// Load stylesheet
|
|
@ -14,11 +14,16 @@ function importExtraPolyfills() {
|
||||||
|
|
||||||
function loadPolyfills() {
|
function loadPolyfills() {
|
||||||
const needsBasePolyfills = !(
|
const needsBasePolyfills = !(
|
||||||
|
// @ts-ignore
|
||||||
Array.prototype.includes &&
|
Array.prototype.includes &&
|
||||||
|
// @ts-ignore
|
||||||
HTMLCanvasElement.prototype.toBlob &&
|
HTMLCanvasElement.prototype.toBlob &&
|
||||||
window.Intl &&
|
window.Intl &&
|
||||||
|
// @ts-ignore
|
||||||
Number.isNaN &&
|
Number.isNaN &&
|
||||||
|
// @ts-ignore
|
||||||
Object.assign &&
|
Object.assign &&
|
||||||
|
// @ts-ignore
|
||||||
Object.values &&
|
Object.values &&
|
||||||
window.Symbol
|
window.Symbol
|
||||||
);
|
);
|
|
@ -5,7 +5,7 @@ import * as OfflinePluginRuntime from '@lcdp/offline-plugin/runtime';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from 'react-dom';
|
||||||
|
|
||||||
import { NODE_ENV } from 'soapbox/build_config';
|
import * as BuildConfig from 'soapbox/build_config';
|
||||||
|
|
||||||
import { default as Soapbox } from './containers/soapbox';
|
import { default as Soapbox } from './containers/soapbox';
|
||||||
import * as monitoring from './monitoring';
|
import * as monitoring from './monitoring';
|
||||||
|
@ -19,11 +19,11 @@ function main() {
|
||||||
monitoring.start();
|
monitoring.start();
|
||||||
|
|
||||||
ready(() => {
|
ready(() => {
|
||||||
const mountNode = document.getElementById('soapbox');
|
const mountNode = document.getElementById('soapbox') as HTMLElement;
|
||||||
|
|
||||||
ReactDOM.render(<Soapbox />, mountNode);
|
ReactDOM.render(<Soapbox />, mountNode);
|
||||||
|
|
||||||
if (NODE_ENV === 'production') {
|
if (BuildConfig.NODE_ENV === 'production') {
|
||||||
// avoid offline in dev mode because it's harder to debug
|
// avoid offline in dev mode because it's harder to debug
|
||||||
OfflinePluginRuntime.install();
|
OfflinePluginRuntime.install();
|
||||||
}
|
}
|
|
@ -1,13 +1,13 @@
|
||||||
import { NODE_ENV, SENTRY_DSN } from 'soapbox/build_config';
|
import * as BuildConfig from 'soapbox/build_config';
|
||||||
|
|
||||||
export const start = () => {
|
export const start = (): void => {
|
||||||
Promise.all([
|
Promise.all([
|
||||||
import(/* webpackChunkName: "error" */'@sentry/react'),
|
import(/* webpackChunkName: "error" */'@sentry/react'),
|
||||||
import(/* webpackChunkName: "error" */'@sentry/tracing'),
|
import(/* webpackChunkName: "error" */'@sentry/tracing'),
|
||||||
]).then(([Sentry, { Integrations: Integrations }]) => {
|
]).then(([Sentry, { Integrations: Integrations }]) => {
|
||||||
Sentry.init({
|
Sentry.init({
|
||||||
dsn: SENTRY_DSN,
|
dsn: BuildConfig.SENTRY_DSN,
|
||||||
environment: NODE_ENV,
|
environment: BuildConfig.NODE_ENV,
|
||||||
debug: false,
|
debug: false,
|
||||||
integrations: [new Integrations.BrowserTracing()],
|
integrations: [new Integrations.BrowserTracing()],
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ export const start = () => {
|
||||||
}).catch(console.error);
|
}).catch(console.error);
|
||||||
};
|
};
|
||||||
|
|
||||||
export const captureException = error => {
|
export const captureException = (error: Error): void => {
|
||||||
import(/* webpackChunkName: "error" */'@sentry/react')
|
import(/* webpackChunkName: "error" */'@sentry/react')
|
||||||
.then(Sentry => {
|
.then(Sentry => {
|
||||||
Sentry.captureException(error);
|
Sentry.captureException(error);
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
import { NODE_ENV } from 'soapbox/build_config';
|
import * as BuildConfig from 'soapbox/build_config';
|
||||||
|
|
||||||
//
|
//
|
||||||
// Tools for performance debugging, only enabled in development mode.
|
// Tools for performance debugging, only enabled in development mode.
|
||||||
|
@ -8,9 +8,9 @@ import { NODE_ENV } from 'soapbox/build_config';
|
||||||
// Also see config/webpack/loaders/mark.js for the webpack loader marks.
|
// Also see config/webpack/loaders/mark.js for the webpack loader marks.
|
||||||
//
|
//
|
||||||
|
|
||||||
let marky;
|
let marky: any;
|
||||||
|
|
||||||
if (NODE_ENV === 'development') {
|
if (BuildConfig.NODE_ENV === 'development') {
|
||||||
if (typeof performance !== 'undefined' && performance.setResourceTimingBufferSize) {
|
if (typeof performance !== 'undefined' && performance.setResourceTimingBufferSize) {
|
||||||
// Increase Firefox's performance entry limit; otherwise it's capped to 150.
|
// Increase Firefox's performance entry limit; otherwise it's capped to 150.
|
||||||
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1331135
|
// See: https://bugzilla.mozilla.org/show_bug.cgi?id=1331135
|
||||||
|
@ -22,14 +22,10 @@ if (NODE_ENV === 'development') {
|
||||||
//window.ReactPerf.start();
|
//window.ReactPerf.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
export function start(name) {
|
export function start(name: string): void {
|
||||||
if (NODE_ENV === 'development') {
|
marky?.mark(name);
|
||||||
marky.mark(name);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function stop(name) {
|
export function stop(name: string): void {
|
||||||
if (NODE_ENV === 'development') {
|
marky?.stop(name);
|
||||||
marky.stop(name);
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -1,6 +1,6 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
export default function ready(loaded) {
|
export default function ready(loaded: () => void): void {
|
||||||
if (['interactive', 'complete'].includes(document.readyState)) {
|
if (['interactive', 'complete'].includes(document.readyState)) {
|
||||||
loaded();
|
loaded();
|
||||||
} else {
|
} else {
|
|
@ -3,7 +3,7 @@
|
||||||
"baseUrl": "app/",
|
"baseUrl": "app/",
|
||||||
"sourceMap": true,
|
"sourceMap": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"module": "es6",
|
"module": "es2022",
|
||||||
"target": "es5",
|
"target": "es5",
|
||||||
"jsx": "react",
|
"jsx": "react",
|
||||||
"allowJs": true,
|
"allowJs": true,
|
||||||
|
|
|
@ -35,7 +35,7 @@ const makeHtmlConfig = (params = {}) => {
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
entry: {
|
entry: {
|
||||||
application: resolve('app/application.js'),
|
application: resolve('app/application.ts'),
|
||||||
},
|
},
|
||||||
|
|
||||||
output: {
|
output: {
|
||||||
|
|
Loading…
Reference in New Issue