Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
06eef19
WIP: Start building app infra
OllysCoding Dec 13, 2022
522af70
Add `Platform` enum
JamieB-gu Dec 14, 2022
3fd8b13
Get apps page to render
OllysCoding Dec 14, 2022
bcf1f0a
feat: add a client side bundle for apps
OllysCoding Dec 14, 2022
c0009a9
Add initial bridget support to DCR
OllysCoding Dec 15, 2022
4aad7b6
add buffer to apps build
OllysCoding Dec 15, 2022
01e04be
Platform-specific components
JamieB-gu Dec 16, 2022
5f04d90
prettier
OllysCoding Dec 16, 2022
55c240e
refactor: don't use '{}' as a type
OllysCoding Dec 16, 2022
0054b0d
wip: lightbox for apps
OllysCoding Dec 19, 2022
8ce235a
`app` => `mobile-apps`
sunnyclimber456 Dec 20, 2022
6e6d65b
Prop drill platform
JamieB-gu Dec 20, 2022
e0c163e
Make fix
JamieB-gu Dec 20, 2022
220ebfc
handle app article routes in prod server
sunnyclimber456 Dec 20, 2022
60da739
add stub window.guardian for frontendAssetsFullURL
sunnyclimber456 Dec 21, 2022
9fe7550
add page ajaxurl
sunnyclimber456 Dec 21, 2022
29fae1f
Merge branch 'main' into spike/render-for-apps
sunnyclimber456 Dec 21, 2022
fa58ece
lint fix
sunnyclimber456 Dec 21, 2022
1edfa49
assert main.js exists in manifest asset hash
sunnyclimber456 Dec 21, 2022
0d078f1
Merge branch 'main' into spike/render-for-apps
sunnyclimber456 Dec 28, 2022
9376572
add undefined contributor check
sunnyclimber456 Dec 28, 2022
2344df5
test for whether in an app environment for determining ASSET_ORIGIN
sunnyclimber456 Dec 29, 2022
be4f63a
improve comment around isApp
sunnyclimber456 Dec 29, 2022
6914e6d
add fontSize.css to page template head for font scaling
sunnyclimber456 Dec 29, 2022
cb87c75
STAVE => STAGE
sunnyclimber456 Dec 30, 2022
cfcc616
add client script to Link header for caching in native apps
sunnyclimber456 Dec 30, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions dotcom-rendering/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"@babel/preset-typescript": "^7.12.7",
"@babel/runtime": "^7.12.5",
"@braze/web-sdk-core": "3.5.1",
"@creditkarma/thrift-server-core": "^1.0.4",
"@cypress/skip-test": "^2.6.0",
"@emotion/babel-plugin": "^11.3.0",
"@emotion/cache": "^11.4.0",
Expand All @@ -71,6 +72,7 @@
"@guardian/ab-core": "^2.0.0",
"@guardian/atoms-rendering": "^24.0.0",
"@guardian/braze-components": "^8.1.3",
"@guardian/bridget": "^2.0.0",
"@guardian/browserslist-config": "^2.0.3",
"@guardian/commercial-core": "^5.0.0",
"@guardian/consent-management-platform": "11.0.0",
Expand Down Expand Up @@ -151,6 +153,7 @@
"babel-plugin-polyfill-corejs3": "^0.6.0",
"babel-plugin-px-to-rem": "https://github.com/guardian/babel-plugin-px-to-rem#v0.1.0",
"babel-plugin-transform-runtime": "^6.23.0",
"buffer": "^6.0.3",
"browserslist": "^4.21.4",
"bundlesize": "^0.18.1",
"chalk": "^4.1.0",
Expand Down
82 changes: 65 additions & 17 deletions dotcom-rendering/scripts/webpack/webpack.config.browser.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const webpack = require('webpack');
const { WebpackManifestPlugin } = require('webpack-manifest-plugin');
const swcConfig = require('./.swcrc.json');
const { getBrowserTargets } = require('./browser-targets');
Expand All @@ -15,7 +16,7 @@ const generateName = (bundle) => {
};

/**
* @param {'legacy' | 'modern' | 'variant'} bundle
* @param {'legacy' | 'modern' | 'variant' | 'apps'} bundle
* @returns {string}
*/
const getLoaders = (bundle) => {
Expand Down Expand Up @@ -48,6 +49,32 @@ const getLoaders = (bundle) => {
},
},
];
case 'apps':
return [
{
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-react',
[
'@babel/preset-env',
{
bugfixes: true,
targets: ['android >= 5', 'ios >= 12'],
},
],
],
compact: true,
},
},
{
loader: 'ts-loader',
options: {
configFile: 'tsconfig.build.json',
transpileOnly: true,
},
},
];
case 'variant':
return [
{
Expand Down Expand Up @@ -93,25 +120,28 @@ const getLoaders = (bundle) => {
};

/**
* @param {{ bundle: 'legacy' | 'modern' | 'variant', sessionId: string }} options
* @param {{ bundle: 'legacy' | 'modern' | 'apps' | 'variant', sessionId: string }} options
* @returns {import('webpack').Configuration}
*/
module.exports = ({ bundle, sessionId }) => ({
entry: {
sentryLoader: './src/web/browser/sentryLoader/init.ts',
bootCmp: './src/web/browser/bootCmp/init.ts',
ga: './src/web/browser/ga/init.ts',
ophan: './src/web/browser/ophan/init.ts',
islands: './src/web/browser/islands/init.ts',
dynamicImport: './src/web/browser/dynamicImport/init.ts',
atomIframe: './src/web/browser/atomIframe/init.ts',
embedIframe: './src/web/browser/embedIframe/init.ts',
newsletterEmbedIframe:
'./src/web/browser/newsletterEmbedIframe/init.ts',
relativeTime: './src/web/browser/relativeTime/init.ts',
initDiscussion: './src/web/browser/initDiscussion/init.ts',
debug: './src/web/browser/debug/init.ts',
},
entry:
bundle === 'apps'
? './src/app/client/init.ts'
: {
sentryLoader: './src/web/browser/sentryLoader/init.ts',
bootCmp: './src/web/browser/bootCmp/init.ts',
ga: './src/web/browser/ga/init.ts',
ophan: './src/web/browser/ophan/init.ts',
islands: './src/web/browser/islands/init.ts',
dynamicImport: './src/web/browser/dynamicImport/init.ts',
atomIframe: './src/web/browser/atomIframe/init.ts',
embedIframe: './src/web/browser/embedIframe/init.ts',
newsletterEmbedIframe:
'./src/web/browser/newsletterEmbedIframe/init.ts',
relativeTime: './src/web/browser/relativeTime/init.ts',
initDiscussion: './src/web/browser/initDiscussion/init.ts',
debug: './src/web/browser/debug/init.ts',
},
output: {
filename: (data) => {
// We don't want to hash the debug script so it can be used in bookmarklets
Expand All @@ -121,10 +151,28 @@ module.exports = ({ bundle, sessionId }) => ({
chunkFilename: generateName(bundle),
publicPath: '',
},
resolve:
bundle === 'apps'
? {
fallback: {
buffer: require.resolve('buffer/'),
},
}
: undefined,
plugins: [
new WebpackManifestPlugin({
fileName: `manifest.${bundle}.json`,
}),
...(bundle === 'apps'
? [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
}),
]
: []),
...(DEV
? [
new GuStatsReportPlugin({
Expand Down
11 changes: 10 additions & 1 deletion dotcom-rendering/scripts/webpack/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const sessionId = uuidv4();
let builds = 0;

/**
* @param {{ platform: 'server' | 'browser.legacy' | 'browser.modern' | 'browser.variant'}} options
* @param {{ platform: 'server' | 'browser.legacy' | 'browser.modern' | 'browser.apps' | 'browser.variant'}} options
* @returns {import('webpack').Configuration}
*/
const commonConfigs = ({ platform }) => ({
Expand Down Expand Up @@ -131,6 +131,15 @@ module.exports = [
sessionId,
}),
),
merge(
commonConfigs({
platform: 'browser.apps',
}),
require(`./webpack.config.browser`)({
bundle: 'apps',
sessionId,
}),
),
...(BUILD_VARIANT
? [
merge(
Expand Down
7 changes: 7 additions & 0 deletions dotcom-rendering/src/app/client/init.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import '../../web/browser/dynamicImport/init.ts';
import '../../web/browser/islands/init.ts';
import '../../web/browser/atomIframe/init.ts';
import '../../web/browser/embedIframe/init.ts';
import '../../web/browser/newsletterEmbedIframe/init.ts';
import '../../web/browser/relativeTime/init.ts';
// import '../../web/browser/initDiscussion/init.ts';
70 changes: 70 additions & 0 deletions dotcom-rendering/src/app/components/ArticlePage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import { css, Global } from '@emotion/react';
import { ArticleDesign } from '@guardian/libs';
import { brandAlt, focusHalo, neutral } from '@guardian/source-foundations';
import { StrictMode } from 'react';
// import { filterABTestSwitches } from '../../model/enhance-switches';
import type { FEArticleType } from '../../types/frontend';
import { FetchCommentCounts } from '../../web/components/FetchCommentCounts.importable';
import { FocusStyles } from '../../web/components/FocusStyles.importable';
import { Island } from '../../web/components/Island';
// import { SetABTests } from './SetABTests.importable';
import { SkipTo } from '../../web/components/SkipTo';
import { DecideLayout } from '../layouts/DecideLayout';

type Props = {
CAPIArticle: FEArticleType;
format: ArticleFormat;
};

/**
* @description
* Article is a high level wrapper for article pages on Dotcom. Sets strict mode and some globals
*
* @param {Props} props
* @param {FEArticleType} props.CAPIArticle - The article JSON data
* @param {NAVType} props.NAV - The article JSON data
* @param {ArticleFormat} props.format - The format model for the article
* */
export const ArticlePage = ({ CAPIArticle, format }: Props) => {
return (
<StrictMode>
<Global
styles={css`
/* Crude but effective mechanism. Specific components may need to improve on this behaviour. */
/* The not(.src...) selector is to work with Source's FocusStyleManager. */
*:focus {
${focusHalo}
}
::selection {
background: ${brandAlt[400]};
color: ${neutral[7]};
}
`}
/>
<SkipTo id="maincontent" label="Skip to main content" />
{(format.design === ArticleDesign.LiveBlog ||
format.design === ArticleDesign.DeadBlog) && (
<SkipTo id={'key-events-carousel'} label="Skip to key events" />
)}
<Island clientOnly={true} deferUntil="idle">
<FocusStyles />
</Island>
{/* <Island clientOnly={true} deferUntil="idle">
<CoreVitals />
</Island> */}
<Island clientOnly={true} deferUntil="idle">
<FetchCommentCounts repeat={true} />
</Island>
{/* <Island clientOnly={true}>
<SetABTests
abTestSwitches={filterABTestSwitches(
CAPIArticle.config.switches,
)}
pageIsSensitive={CAPIArticle.config.isSensitive}
isDev={!!CAPIArticle.config.isDev}
/>
</Island> */}
<DecideLayout CAPIArticle={CAPIArticle} format={format} />
</StrictMode>
);
};
64 changes: 64 additions & 0 deletions dotcom-rendering/src/app/layouts/DecideLayout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { ArticleDesign, ArticleDisplay } from '@guardian/libs';
import type { ArticleFormat } from '@guardian/libs';
import type { FEArticleType } from '../../types/frontend';
import { StandardLayout } from './StandardLayout';

type Props = {
CAPIArticle: FEArticleType;
format: ArticleFormat;
};

export const DecideLayout = ({ CAPIArticle, format }: Props) => {
switch (format.display) {
case ArticleDisplay.Immersive: {
switch (format.design) {
case ArticleDesign.Interactive: {
return <div>Not Supported</div>;
}
default: {
return <div>Not Supported</div>;
}
}
}
case ArticleDisplay.NumberedList:
case ArticleDisplay.Showcase: {
switch (format.design) {
case ArticleDesign.LiveBlog:
case ArticleDesign.DeadBlog:
return <div>Not Supported</div>;
case ArticleDesign.Comment:
case ArticleDesign.Editorial:
case ArticleDesign.Letter:
return <div>Not Supported</div>;
default:
return <div>Not Supported</div>;
}
}
case ArticleDisplay.Standard:
default: {
switch (format.design) {
case ArticleDesign.Interactive:
return <div>Not Supported</div>;
case ArticleDesign.FullPageInteractive: {
return <div>Not Supported</div>;
}
case ArticleDesign.LiveBlog:
case ArticleDesign.DeadBlog:
return <div>Not Supported</div>;
case ArticleDesign.Comment:
case ArticleDesign.Editorial:
case ArticleDesign.Letter:
return <div>Not Supported</div>;
case ArticleDesign.NewsletterSignup:
return <div>Not Supported</div>;
default:
return (
<StandardLayout
CAPIArticle={CAPIArticle}
format={format}
/>
);
}
}
}
};
Loading