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 all 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.13",
"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": "b@bayer.ws",
"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/*"]
}
}
}
4 changes: 2 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -13799,7 +13799,7 @@ tslib@1.10.0:
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 @@ -13887,7 +13887,7 @@ typescript@3.8.2:
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