Skip to content

Typescript support #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 128 commits into from
May 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
eff8dce
ts
vabruzzo Oct 3, 2018
78a1074
fix importer
vabruzzo Oct 3, 2018
8f95137
fix ts babel loader order
vabruzzo Oct 3, 2018
a26f1df
add typescript plugin ars
vabruzzo Oct 8, 2018
8cccfc4
artifacts
vabruzzo Oct 9, 2018
0ef017d
rm artifacts
vabruzzo Oct 9, 2018
eee0f26
add resolve extensitons
vabruzzo Oct 9, 2018
e943a3f
artifacts dir, alias
vabruzzo Oct 10, 2018
4289d45
adds 'clientEntry' and 'serverEntry' as package.json config
tomconroy Oct 11, 2018
ac7a067
Merge pull request #46 from firstlookmedia/entry-config
tomconroy Oct 11, 2018
b152582
mode:production in server prod build
tomconroy Nov 20, 2018
63490e7
Merge pull request #50 from firstlookmedia/server-mode
tomconroy Nov 20, 2018
956109b
ts-jest support
vabruzzo Nov 27, 2018
dbeb97c
ts-jest support
vabruzzo Nov 27, 2018
af17ac3
ts-jest support
vabruzzo Nov 27, 2018
a3b6f2e
ts-jest support
vabruzzo Nov 27, 2018
e7b201f
ts-jest support
vabruzzo Nov 27, 2018
ee97c86
ts-jest support
vabruzzo Nov 27, 2018
d6eeeff
ts-jest support
vabruzzo Nov 27, 2018
c8a30bc
ts-jest support
vabruzzo Nov 27, 2018
cdcb6ad
ts-jest support
vabruzzo Nov 27, 2018
80ca523
ts-jest support
vabruzzo Nov 27, 2018
b8c6e08
ts-jest support
vabruzzo Nov 27, 2018
dfbcf49
ts-jest support
vabruzzo Nov 27, 2018
e78872d
revert ts-jest changes
Nov 29, 2018
b8e4207
rethink server-side hot code reloading
tomconroy Dec 4, 2018
e88a522
Merge pull request #51 from firstlookmedia/server-hot
tomconroy Dec 6, 2018
87f5cf7
version
tomconroy Dec 6, 2018
625a121
fix repo name
tomconroy Dec 6, 2018
16e7c52
testing (#52)
Dec 7, 2018
bcfc2c8
Requires React 16.3+ as a peer dependency (fixes testing issues with …
carlyle Dec 7, 2018
789fd2a
Testing: includes .js(x) in test coverage as well
carlyle Dec 7, 2018
ae52195
v2.0.0-rc4
carlyle Dec 7, 2018
b5050e9
introduce ASSETS_S3_KEY_PREFIX env to set prefix of S3 assets/ key
jefforulez Dec 11, 2018
82ae1b8
Merge branch 'typescript-support' into jeffo/asset_s3_key
carlyle Dec 12, 2018
6cf664b
Merge pull request #53 from firstlookmedia/jeffo/asset_s3_key
carlyle Dec 12, 2018
a05110e
2.0.0-rc5
carlyle Dec 12, 2018
7c96c49
edit jest coverage config
vabruzzo Dec 28, 2018
ced358c
fix loading css files from node_modules; use new exportOnlyLocals
tomconroy Jan 17, 2019
d29ca7e
Merge pull request #54 from firstlookmedia/css-external-modules
tomconroy Jan 17, 2019
b2ce575
version
tomconroy Jan 17, 2019
487a78a
Re-yarn
Feb 14, 2019
37acef6
Adjust configuration of coverage target paths
Feb 14, 2019
2ef4f5f
Adds an .nvmrc and an 'engines' entry to package.json for a more cons…
carlyle Feb 19, 2019
1dd517d
Merge pull request #56 from firstlookmedia/nvmrc
tomconroy Feb 25, 2019
e1162b4
Re-yarn again
Feb 25, 2019
be33a54
Merge branch 'typescript-support' of github.com:firstlookmedia/react-…
Feb 25, 2019
71540d0
Merge branch 'typescript-support' into flm-3726
Feb 25, 2019
8caef95
Re-yarn again
Feb 25, 2019
06a53c9
Reverts yarn.lock
carlyle Feb 26, 2019
6b6d31e
Merge pull request #55 from firstlookmedia/flm-3726
Feb 26, 2019
7eb5ee5
node engines edit
vabruzzo Feb 27, 2019
e19abb4
Typescript support v2 topic pq (#57)
Feb 27, 2019
9b01b9d
fix pq flags
vabruzzo Feb 27, 2019
aa2d709
Merge pull request #58 from firstlookmedia/fix-pq-flags
tomconroy Feb 27, 2019
e9be347
edit persisted queries checks
vabruzzo Mar 7, 2019
cde9891
prettier, update readme
vabruzzo Mar 7, 2019
a5020f1
edit pq readme
vabruzzo Mar 7, 2019
bd98a9d
edit pq readme
vabruzzo Mar 7, 2019
5fcb813
Merge pull request #59 from firstlookmedia/fix-pq-env-stuff
tomconroy Mar 7, 2019
cd1f067
cache bust pq
vabruzzo Mar 11, 2019
2e23c9e
bump version
vabruzzo Mar 11, 2019
ff36ab5
fix filename
vabruzzo Mar 11, 2019
199abe0
Merge pull request #60 from firstlookmedia/persisted-query-cache-bustmn
tomconroy Mar 11, 2019
34f9a30
Flp 4691 code splitting (#62)
May 6, 2019
065755e
bump version (#63)
May 6, 2019
b0a47c6
Babel bugfix (#64)
May 6, 2019
2b97304
rm decorator support (#65)
May 6, 2019
21a3a11
bump hot loader to support relay v4 and accompanying version bumps (#66)
Jun 24, 2019
7d6a477
add QueryRenderer mocks for testing components with QueryRenderers in…
tomconroy Jun 27, 2019
ee0d0bf
Merge pull request #67 from firstlookmedia/relay-mocks
tomconroy Jun 27, 2019
24cfb6d
version
tomconroy Jun 27, 2019
6d07b88
version
tomconroy Jun 27, 2019
4194cf0
allows project to specify in package json
tomconroy Jun 27, 2019
d3676d4
Merge pull request #68 from firstlookmedia/relay-compat-configurable
tomconroy Jun 27, 2019
fc09d0d
version
tomconroy Jun 27, 2019
d052d89
Support data component testing (#69)
Jul 16, 2019
a82afe0
Babel macros support / ti modern code splitting support (#70)
Jul 24, 2019
7f22630
Updates react-relay, relay-compiler peer dependencies; adds missing d…
carlyle Jul 30, 2019
91a02ca
Merge pull request #71 from firstlookmedia/update-peers
carlyle Jul 30, 2019
c7efd10
v2.0.0-rc23
carlyle Jul 30, 2019
1c09e80
Bugfix/ti modern splitting/preset-env (#73)
Jul 31, 2019
61cd56a
update yarn.lock
vabruzzo Jul 31, 2019
76381e1
fix browserslist error downstream (#74)
Jul 31, 2019
4e59802
fix css processor on production
vabruzzo Jul 31, 2019
782db3f
bump version
vabruzzo Jul 31, 2019
319cc9f
Merge pull request #75 from firstlookmedia/css-minify-fix
carlyle Jul 31, 2019
2be8786
makes react-hot-loader optional
tomconroy Aug 7, 2019
6c68940
Merge pull request #76 from firstlookmedia/hot-loader-optional
tomconroy Aug 7, 2019
633aba0
version
tomconroy Aug 7, 2019
47b6b2f
Adds messageformat build support to webpack for precompiling translat…
carlyle Aug 9, 2019
f8c0073
Merge pull request #77 from firstlookmedia/messageformat
carlyle Aug 12, 2019
1f81c8d
v2.0.0-rc28
carlyle Aug 12, 2019
14728e8
print stack trace in case of webpack error
tomconroy Oct 2, 2019
f8e4930
sass
vabruzzo Apr 28, 2022
8bd3203
bump node
vabruzzo Apr 28, 2022
afee5b4
bump node
vabruzzo Apr 28, 2022
381ff17
sass-loader
vabruzzo Apr 28, 2022
a0a749c
sass
vabruzzo Apr 28, 2022
fd1c671
fix
vabruzzo Apr 28, 2022
cd78038
bump
vabruzzo Apr 28, 2022
b3d73f9
bump
vabruzzo Apr 28, 2022
da7b451
bump
vabruzzo Apr 28, 2022
25aee59
fix
vabruzzo Apr 28, 2022
4086bf3
babel
vabruzzo Apr 28, 2022
4a81779
bump
vabruzzo Apr 28, 2022
69f134e
bump
vabruzzo Apr 28, 2022
923963c
bump
vabruzzo Apr 28, 2022
05becd7
corejs
vabruzzo Apr 28, 2022
a43a13b
bump
vabruzzo Apr 28, 2022
fa9e9ce
bump
vabruzzo Apr 28, 2022
429e75e
Revert "bump"
vabruzzo Apr 28, 2022
c7fda5b
bump
vabruzzo Apr 28, 2022
89c3e6a
bump
vabruzzo Apr 28, 2022
a267ae1
runtime
vabruzzo Apr 28, 2022
87f5878
fix
vabruzzo Apr 28, 2022
f08edea
Revert "fix"
vabruzzo Apr 28, 2022
0da2eb0
relay test
vabruzzo Apr 28, 2022
6d6e045
bump
vabruzzo Apr 28, 2022
8a25fc9
up
vabruzzo Apr 28, 2022
424edcb
bump
vabruzzo Apr 28, 2022
2dc42aa
relay
vabruzzo Apr 28, 2022
652c7ae
fix
vabruzzo Apr 28, 2022
b38f908
bump
vabruzzo Apr 29, 2022
1c79b6c
bump
vabruzzo Apr 29, 2022
ec7f795
r17
vabruzzo Apr 29, 2022
e3fd6e1
update package version
jcseo3 May 2, 2022
54fd4b4
Merge pull request #100 from firstlookmedia/6561-rs-upgrade
jcseo3 May 2, 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
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ jobs:
build:
working_directory: ~/react-scripts
docker:
- image: circleci/node:6
- image: circleci/node:12
steps:
- checkout
- restore_cache:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ template/schema.graphql
yarn-error.log
.watchmanconfig
.tern-port
complete.queryMap.json
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
8
5 changes: 5 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"trailingComma": "all",
"singleQuote": true,
"printWidth": 90
}
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,11 @@ To install on OSX `brew bundle` in this directory.

## Persisted queries

By default, sites will not persist static queries. To enable persisted queries:
To enable persisted queries:

1. add `PERSIST_QUERIES: "true"` to all build circle configs
2. add `QUERIES_S3_BUCKET` property to all build and deploy circle configs and point it to the s3 bucket where the site's queries live
3. upgrade to the newest version of React scripts that has the `get` and `post` fetcher methods
4. install our forked version of relay compiler: https://github.com/firstlookmedia/relay contains the .tar.gz of the compiler and you refer to it like so in the `package.json`: https://github.com/firstlookmedia/relay/releases/download/v1.5.0-flm.1/relay-compiler-1.5.0-flm.1.tar.gz
1. Add `PERSIST_QUERIES: "true"` in the build and runtime environments
2. Point `QUERIES_S3_BUCKET` to an s3 bucket during build time to deploy queries, making them accessible to the graphql backend
3. Upgrade to the newest version of React scripts that has the `GET` and `POST` fetcher methods
4. Upgrade to relay >= 3.0

Note: persisted queries are always turned off during local development.

### relay compiler

We are using a forked version of relay similar to what the artsy folks are doing. Hopefully, this fork will get merged into relay proper, at which point we won't need to do anything special to get persisted static queries to work. Until then, we will need to stick to relay version `1.5.0` and if we do need to upgrade we'll have to update our fork, rebuild the compiler, and release it. The artsy folks and others have done an excellent job of keeping this fork up to date with subsequent relay releases, so this should not pose much a problem. In fact, it would be great for us to help with merging upstream relay releases into the PR version on the relay repository if necessary.

1 change: 1 addition & 0 deletions bin/react-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const args = process.argv.slice(3);

switch (script) {
case 'build':
case 'build-queries':
case 'start':
case 'upload':
case 'upload-queries':
Expand Down
52 changes: 52 additions & 0 deletions config/babelOptions.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
const packageConfig = require('./packageConfig');

const useReactHotLoader = typeof packageConfig.useReactHotLoader !== 'undefined'
? packageConfig.useReactHotLoader
: true;

const babelOptions = {
passPerPreset: true,
presets: [
[
'@babel/preset-env',
{
useBuiltIns: 'entry',
corejs: 3,
},
],
'@babel/typescript',
'@babel/react',
],
plugins: [
[
'@babel/transform-runtime',
{
corejs: 3,
},
],
'@loadable/babel-plugin',
useReactHotLoader && 'react-hot-loader/babel',
[
'relay',
{
compat: packageConfig.relayCompatMode || false,
artifactDirectory: 'src/__generated__',
schema: 'schema.graphql',
},
],
'@babel/plugin-syntax-dynamic-import',
'@babel/plugin-syntax-import-meta',
'@babel/plugin-proposal-class-properties',
'@babel/plugin-proposal-json-strings',
'@babel/plugin-proposal-function-sent',
'@babel/plugin-proposal-export-namespace-from',
'@babel/plugin-proposal-numeric-separator',
'@babel/plugin-proposal-throw-expressions',
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-nullish-coalescing-operator',
'@babel/plugin-proposal-object-rest-spread',
'@babel/plugin-transform-for-of',
].filter(Boolean),
};

module.exports = babelOptions;
9 changes: 9 additions & 0 deletions config/packageConfig.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const path = require('path');

const packageConfig = require(path.resolve('package.json'));

const reactScriptPackageConfig = {
...packageConfig['react-scripts'],
};

module.exports = reactScriptPackageConfig;
46 changes: 32 additions & 14 deletions config/webpack.client.dev.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,39 @@
const webpack = require('webpack');
const merge = require('webpack-merge');
const path = require('path');
const LoadablePlugin = require('@loadable/webpack-plugin');
const defaults = require('./webpack.defaults');

const config = merge.smart({
module: {
rules: [{
test: /\.css$/,
use: ['style-loader'],
}, {
test: /\.scss$/,
use: ['style-loader'],
}],
const config = merge.smart(
{
module: {
rules: [
{
test: /\.css$/,
include: path.resolve('src'),
use: ['style-loader'],
},
{
test: /\.css$/,
include: path.resolve('node_modules'),
use: ['style-loader'],
},
{
test: /\.scss$/,
use: ['style-loader'],
},
],
},
},
}, defaults, {
devtool: 'eval-source-map',
entry: ['webpack-hot-middleware/client'],
plugins: [new webpack.HotModuleReplacementPlugin()],
});
defaults,
{
devtool: 'eval-source-map',
entry: ['webpack-hot-middleware/client'],
plugins: [
new LoadablePlugin({ filename: 'stats.json', writeToDisk: true }),
new webpack.HotModuleReplacementPlugin(),
],
},
);

module.exports = config;
89 changes: 63 additions & 26 deletions config/webpack.client.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,35 +4,72 @@ const ProgressBarPlugin = require('progress-bar-webpack-plugin');
const merge = require('webpack-merge');
const MiniCSSExtractPlugin = require('mini-css-extract-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const path = require('path');
const LoadablePlugin = require('@loadable/webpack-plugin');
const defaults = require('./webpack.defaults');
const babelOptions = require('./babelOptions');

const config = merge.smart({
module: {
rules: [{
test: /\.css$/,
use: [MiniCSSExtractPlugin.loader],
}, {
test: /\.scss$/,
use: [MiniCSSExtractPlugin.loader],
}],
const config = merge.smart(
{
module: {
rules: [
{
test: /\.css$/,
include: path.resolve('src'),
use: [MiniCSSExtractPlugin.loader],
},
{
test: /\.css$/,
include: path.resolve('node_modules'),
use: [MiniCSSExtractPlugin.loader],
},
{
test: /\.scss$/,
use: [MiniCSSExtractPlugin.loader],
},
{
test: /\.tsx*$/,
include: [path.resolve('src')],
use: [
{
loader: 'babel-loader',
options: babelOptions,
},
{
loader: 'ts-loader',
},
],
},
],
},
},
}, defaults, {
mode: 'production',
output: {
filename: '[hash].js',
defaults,
{
mode: 'production',
output: {
filename: '[hash].js',
},
plugins: [
new LoadablePlugin({ filename: 'stats.json', writeToDisk: true }),
new ManifestPlugin({ fileName: 'manifest.json' }),
new ManifestPlugin({ fileName: `manifest.${Date.now()}.json` }),
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"',
}),
new ProgressBarPlugin(),
new MiniCSSExtractPlugin({
filename: '[contenthash].css',
}),
new OptimizeCSSAssetsPlugin({
cssProcessorOptions: {
map: {
inline: false,
},
reduceIdents: false,
},
}),
],
},
plugins: [
new ManifestPlugin({ fileName: 'manifest.json' }),
new ManifestPlugin({ fileName: `manifest.${Date.now()}.json` }),
new webpack.DefinePlugin({
'process.env.NODE_ENV': '"production"',
}),
new ProgressBarPlugin(),
new MiniCSSExtractPlugin({
filename: '[contenthash].css',
}),
new OptimizeCSSAssetsPlugin({}),
],
});
);

module.exports = config;
Loading