Skip to content
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

[legacy-framework] bug(webpack): Create webpack package to avoid context bugs #42

Merged
merged 4 commits into from
Mar 5, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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 examples/first-demo/next.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
const {withBlitz} = require('@blitzjs/core')
const {withBlitz} = require('@blitzjs/webpack')

module.exports = withBlitz({})
2 changes: 0 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@
"@testing-library/react": "9.4.1",
"@types/react": "16.9.23",
"next": "9.2.3-canary.8",
"next-compose-plugins": "2.2.0",
"next-transpile-modules": "3.0.2",
"null-loader": "3.0.0",
"prisma2": "2.0.0-preview022"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/Form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function({children, action, method, ...props}: {[index: string]:
// Warm the lamba
// TODO: Only do this once per route
fetch(action, {method: 'HEAD'})
}, [])
}, [action])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems unrelated to the rest of the PR but good catch :)

Copy link
Collaborator Author

@ryardley ryardley Mar 5, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup linting error was preventing me from doing something ... committing I think.


return (
<form
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
export * from './components'
export * from './controller'
export {default as withBlitz} from './webpack'
4 changes: 4 additions & 0 deletions packages/webpack/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*.log
.DS_Store
node_modules
dist
40 changes: 40 additions & 0 deletions packages/webpack/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
"version": "0.1.0",
"license": "MIT",
"main": "dist/index.js",
"files": [
"dist"
],
"scripts": {
"start": "tsdx watch",
"build": "tsdx build",
"test": "tsdx test",
"lint": "tsdx lint",
"prepare": "tsdx build"
},
"peerDependencies": {},
"husky": {
"hooks": {
"pre-commit": "tsdx lint"
}
},
"name": "@blitzjs/webpack",
"author": {
"name": "Brandon Bayer",
"email": "[email protected]",
"url": "https://twitter.com/flybayer"
},
"module": "dist/webpack.esm.js",
"typings": "dist/packages/webpack/src",
"devDependencies": {
"@types/jest": "^25.1.3",
"husky": "^4.2.3",
"tsdx": "^0.12.3",
"tslib": "^1.11.1",
"typescript": "^3.8.3"
},
"dependencies": {
"next-compose-plugins": "^2.2.0",
"next-transpile-modules": "^3.0.2"
}
}
1 change: 1 addition & 0 deletions packages/webpack/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export {withBlitz} from './withBlitz'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const withPlugins = require('next-compose-plugins')
const withTM = require('next-transpile-modules')(['@blitzjs/core'])

export default function(nextConfig: Record<any, any> = {}) {
export function withBlitz(nextConfig: Record<any, any> = {}) {
const plugins = []
if (process.env.NODE_ENV === 'development') {
// This is needed during monorepo development so that examples auto reload when packages change
Expand Down
19 changes: 19 additions & 0 deletions packages/webpack/test/withBlitz.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {withBlitz} from '../src'

describe('withBlitz', () => {
it('alters the webpack config as expeted', () => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a spelling correction. Should be 'expected'.

const nextConfigFn = withBlitz({})
const newNext = nextConfigFn('', {defaultConfig: {}})
const newWebpack = newNext.webpack({module: {rules: []}}, {})
expect(newWebpack).toEqual({
module: {
rules: [
{
test: /@prisma\/client/,
use: 'null-loader',
},
],
},
})
})
})
13 changes: 13 additions & 0 deletions packages/webpack/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.json",
"include": ["src", "test"],
"exclude": ["node_modules"],
"compilerOptions": {
"baseUrl": "./",
"declarationDir": "./dist",
"downlevelIteration": true,
"paths": {
"*": ["src/*", "node_modules/*"]
}
}
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10307,7 +10307,7 @@ neo-async@^2.5.0, neo-async@^2.6.0, neo-async@^2.6.1:
resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c"
integrity sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw==

[email protected]:
next-compose-plugins@^2.2.0:
ryardley marked this conversation as resolved.
Show resolved Hide resolved
version "2.2.0"
resolved "https://registry.yarnpkg.com/next-compose-plugins/-/next-compose-plugins-2.2.0.tgz#95cd8eb40ab0652070d76572fb648354191628b0"
integrity sha512-ChUlpT9tWfJ7YxqGw/WQ2T1gf8EeX93n1XqeQw0lkvGa7seszahvF4eOZUJoq7Hetsbzg4UHVnPoCXfXTyQR3g==
Expand All @@ -10317,7 +10317,7 @@ next-tick@~1.0.0:
resolved "https://registry.yarnpkg.com/next-tick/-/next-tick-1.0.0.tgz#ca86d1fe8828169b0120208e3dc8424b9db8342c"
integrity sha1-yobR/ogoFpsBICCOPchCS524NCw=

[email protected]:
next-transpile-modules@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/next-transpile-modules/-/next-transpile-modules-3.0.2.tgz#b289698d453bb7346fd768da171b53a740bfe436"
integrity sha512-w3WsyxvkJ3ws16InHwXhlDaOyG6Peo4co9U2sVBMePwEDo9r3SsbzX7p43sLUTYbpuA2t9iwJoCXkj/4BuD3Qw==
Expand Down Expand Up @@ -14652,7 +14652,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.10.0.tgz#c3c19f95973fb0a62973fb09d90d961ee43e5c8a"
integrity sha512-qOebF53frne81cf0S9B41ByenJ3/IuH8yJKngAX35CmiZySA0khhkovshKK+jGCaMnVomla7gVlIcc3EvKPbTQ==

tslib@^1, tslib@^1.10.0, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
tslib@^1, tslib@^1.10.0, tslib@^1.11.1, tslib@^1.8.1, tslib@^1.9.0, tslib@^1.9.3:
version "1.11.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.1.tgz#eb15d128827fbee2841549e171f45ed338ac7e35"
integrity sha512-aZW88SY8kQbU7gpV19lN24LtXh/yD4ZZg6qieAJDDg+YBsJcSmLGK9QpnUjAKVG/xefmvJGd1WUmfpT/g6AJGA==
Expand Down Expand Up @@ -14740,7 +14740,7 @@ [email protected]:
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.2.tgz#91d6868aaead7da74f493c553aeff76c0c0b1d5a"
integrity sha512-EgOVgL/4xfVrCMbhYKUQTdF37SQn4Iw73H5BgCrF1Abdun7Kwy/QZsE/ssAy0y4LxBbvua3PIbFsbRczWWnDdQ==

typescript@^3.7.3, typescript@^3.7.5:
typescript@^3.7.3, typescript@^3.7.5, typescript@^3.8.3:
version "3.8.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-3.8.3.tgz#409eb8544ea0335711205869ec458ab109ee1061"
integrity sha512-MYlEfn5VrLNsgudQTVJeNaQFUAI7DkhnOjdpAp4T+ku1TfQClewlbSuTVHiA+8skNBgaf02TL/kLOvig4y3G8w==
Expand Down