Skip to content
This repository was archived by the owner on Mar 30, 2022. It is now read-only.

Commit a568356

Browse files
committed
add packages, utils, and examples
1 parent ec8315e commit a568356

File tree

16 files changed

+1781
-361
lines changed

16 files changed

+1781
-361
lines changed

babel.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ module.exports = {
1010
'@emotion/babel-preset-css-prop',
1111
],
1212
plugins: [
13+
'babel-plugin-transform-typescript-metadata',
14+
['@babel/plugin-proposal-decorators', { legacy: true }],
15+
['@babel/plugin-proposal-class-properties', { loose: true }],
1316
'@babel/plugin-proposal-optional-chaining',
1417
'@babel/plugin-proposal-nullish-coalescing-operator',
1518
],

configs/env.mapping.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const path = require('path');
33
require('dotenv').config({
44
path: path.join(__dirname, `../.env/${process.env.NODE_ENV}.env`),
55
});
6+
const packageLockJson = require('../package-lock.json');
67

78
// env mapping for exposure to client
89
module.exports = {
@@ -14,4 +15,5 @@ module.exports = {
1415
MANIEFST_PATH: process.env.MANIEFST_PATH,
1516
ICON_192_PATH: process.env.ICON_192_PATH,
1617
FAV_ICON_PATH: process.env.FAV_ICON_PATH,
18+
SQL_JS_VERSION: packageLockJson.dependencies['sql.js'].version,
1719
};

next.config.js

Lines changed: 63 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-var-requires */
22
const withPWA = require('next-pwa');
3+
const withTM = require('next-transpile-modules')(['typeorm/browser']);
4+
const webpack = require('webpack');
35
const defaultCache = require('next-pwa/cache');
46
const envMapping = require('./configs/env.mapping');
57

@@ -17,51 +19,69 @@ const encodeUriTransform = async (manifestEntries) => {
1719
};
1820

1921
module.exports = () =>
20-
withPWA({
21-
env: envMapping,
22-
target: 'serverless',
23-
poweredByHeader: false,
24-
assetPrefix: LINK_PREFIX,
22+
withPWA(
23+
withTM({
24+
webpack: (config, { isServer }) => {
25+
config.plugins.push(
26+
new webpack.ProvidePlugin({
27+
'window.SQL': 'sql.js/dist/sql-wasm.js',
28+
})
29+
);
30+
if (!isServer) {
31+
config.node = {
32+
fs: 'empty',
33+
net: 'empty',
34+
tls: 'empty',
35+
};
36+
}
37+
return config;
38+
},
2539

26-
pwa: {
27-
disable: !isProd,
28-
subdomainPrefix: LINK_PREFIX,
29-
dest: 'public',
30-
manifestTransforms: [encodeUriTransform],
31-
runtimeCaching: [
32-
...defaultCache,
33-
{
34-
urlPattern: /^https?.*/,
35-
handler: 'NetworkFirst',
36-
options: {
37-
cacheName: 'offlineCache',
38-
networkTimeoutSeconds: 15,
39-
expiration: {
40-
maxEntries: 150,
41-
maxAgeSeconds: 30 * 24 * 60 * 60,
42-
},
43-
cacheableResponse: {
44-
statuses: [0, 200],
40+
env: envMapping,
41+
target: 'serverless',
42+
poweredByHeader: false,
43+
assetPrefix: LINK_PREFIX,
44+
45+
pwa: {
46+
disable: !isProd,
47+
subdomainPrefix: LINK_PREFIX,
48+
dest: 'public',
49+
manifestTransforms: [encodeUriTransform],
50+
runtimeCaching: [
51+
...defaultCache,
52+
{
53+
urlPattern: /^https?.*/,
54+
handler: 'NetworkFirst',
55+
options: {
56+
cacheName: 'offlineCache',
57+
networkTimeoutSeconds: 15,
58+
expiration: {
59+
maxEntries: 150,
60+
maxAgeSeconds: 30 * 24 * 60 * 60,
61+
},
62+
cacheableResponse: {
63+
statuses: [0, 200],
64+
},
4565
},
4666
},
47-
},
48-
{
49-
urlPattern: ({ event }) => event.request.mode === 'navigate',
50-
handler: 'CacheFirst',
51-
options: {
52-
cacheName: 'offlineCache',
53-
expiration: {
54-
maxEntries: 150,
55-
maxAgeSeconds: 30 * 24 * 60 * 60,
56-
},
57-
cacheableResponse: {
58-
statuses: [0, 200],
67+
{
68+
urlPattern: ({ event }) => event.request.mode === 'navigate',
69+
handler: 'CacheFirst',
70+
options: {
71+
cacheName: 'offlineCache',
72+
expiration: {
73+
maxEntries: 150,
74+
maxAgeSeconds: 30 * 24 * 60 * 60,
75+
},
76+
cacheableResponse: {
77+
statuses: [0, 200],
78+
},
5979
},
6080
},
61-
},
62-
],
63-
navigationPreload: true,
64-
// publicExcludes: [],
65-
// exclude: ['**/node_modules/**/*'],
66-
},
67-
});
81+
],
82+
navigationPreload: true,
83+
// publicExcludes: [],
84+
// exclude: ['**/node_modules/**/*'],
85+
},
86+
})
87+
);

0 commit comments

Comments
 (0)