Skip to content

Commit

Permalink
Update dependencies, dev-dependencies
Browse files Browse the repository at this point in the history
This updates the dependencies and dev-dependencies in `packages/`.
Unfortunately, either updating to webpack 5 or updating to react 17 crash the
webpack loader with a react error, with an [invalid hook call
warning](https://reactjs.org/warnings/invalid-hook-call-warning.html) for
`useMDXComponents`:

<https://github.com/mdx-js/mdx/blob/dafdf6d70affa5dba0b3b7070f7a310b70bbf775/packages/react/src/context.js#L15>

Which might have to do with the magic of shortcodes (#1385), or something else,
I have no clue.

Furthermore, this loosens package dependencies instead of locking them,
which relates to GH-865, GH-1015, and GH-1267.
It was a long and divided discussion before and the reason for changing now is:
While the package currently doesn’t break easily (it was mentioned that unlocking
packages might cause that), we are currently *locked* on security vulnerabilities.
We’re not getting any patches, and MDX isn’t released that frequently or
maintained that actively, so MDX users are stuck.
If folks want to lock: npm and yarn have package locks.

Closes GH-1267.
Closes GH-1375.
  • Loading branch information
wooorm committed Dec 18, 2020
1 parent dafdf6d commit e679f4e
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 416 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,22 +40,22 @@
"babel-loader": "^8.2.0",
"dtslint": "^4.0.0",
"eslint": "^7.13.0",
"eslint-config-prettier": "^6.11.0",
"eslint-config-prettier": "^7.0.0",
"eslint-config-xo": "^0.33.0",
"eslint-formatter-friendly": "^7.0.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-mdx": "^1.8.0",
"eslint-plugin-prettier": "^3.1.4",
"eslint-plugin-react": "^7.21.0",
"gatsby": "2.24.3",
"gatsby": "^2.24.3",
"gatsby-plugin-mdx": "^1.2.27",
"husky": "^4.3.0",
"jest": "^26.6.0",
"lerna": "^3.22.1",
"lint-staged": "^10.5.0",
"prettier": "^2.1.0",
"remark-preset-prettier": "^0.4.0",
"remark-preset-wooorm": "^7.0.0",
"remark-preset-wooorm": "^8.0.0",
"rimraf": "^3.0.0",
"typescript": "^4.0.0",
"yarn-deduplicate": "^3.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-apply-mdx-type-props/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const {types: t} = require('@babel/core')
const {declare} = require('@babel/helper-plugin-utils')

const startsWithCapitalLetter = str => /^[A-Z]/.test(str)
Expand All @@ -10,6 +9,7 @@ class BabelPluginApplyMdxTypeProp {

this.plugin = declare(api => {
api.assertVersion(7)
const {types: t} = api

return {
visitor: {
Expand Down
5 changes: 1 addition & 4 deletions packages/babel-plugin-apply-mdx-type-props/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@
"remark",
"babel"
],
"peerDependencies": {
"@babel/core": "^7.10.5"
},
"dependencies": {
"@babel/helper-plugin-utils": "7.10.4"
"@babel/helper-plugin-utils": "^7.10.4"
},
"scripts": {
"test-api": "jest test",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-extract-export-names/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"babel"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.10.4"
"@babel/helper-plugin-utils": "^7.10.4"
},
"scripts": {
"test-api": "jest test",
Expand Down
2 changes: 1 addition & 1 deletion packages/babel-plugin-extract-import-names/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"babel"
],
"dependencies": {
"@babel/helper-plugin-utils": "7.10.4"
"@babel/helper-plugin-utils": "^7.10.4"
},
"scripts": {
"test-api": "jest test",
Expand Down
2 changes: 1 addition & 1 deletion packages/loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"dependencies": {
"@mdx-js/mdx": "^2.0.0-next.8",
"@mdx-js/react": "^2.0.0-next.8",
"loader-utils": "2.0.0"
"loader-utils": "^2.0.0"
},
"devDependencies": {
"memory-fs": "^0.5.0",
Expand Down
11 changes: 11 additions & 0 deletions packages/loader/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const {mdx} = require('../../react')

const transform = (filePath, options) => {
return new Promise((resolve, reject) => {
// Webpack 5: const fs = new MemoryFs()
const compiler = webpack({
context: __dirname,
entry: filePath,
Expand Down Expand Up @@ -38,19 +39,29 @@ const transform = (filePath, options) => {
}
})

// Webpack 5: compiler.outputFileSystem = fs
compiler.outputFileSystem = new MemoryFs()

compiler.run((err, stats) => {
if (err) {
reject(err)
} else {
// Webpack 5:
// resolve(
// {source: fs.readFileSync(path.join(__dirname, '..', 'dist', 'main.js'), 'utf8')}
// )
resolve(stats.toJson().modules.find(m => m.name === filePath))
}
})
})
}

const run = value => {
// Webpack 5 (replace everything in this function with):
// const val = 'return ' + value.replace(/__webpack_require__\(0\)/, 'return $&')
//
// // eslint-disable-next-line no-new-func
// return new Function(val)().default
// Replace import/exports w/ parameters and return value.
const val = value
.replace(
Expand Down
20 changes: 10 additions & 10 deletions packages/mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,21 @@
"babel-plugin-apply-mdx-type-prop": "^2.0.0-next.8",
"babel-plugin-extract-export-names": "^2.0.0-next.8",
"babel-plugin-extract-import-names": "^2.0.0-next.8",
"detab": "2.0.3",
"hast-to-hyperscript": "9.0.0",
"lodash.uniq": "4.5.0",
"detab": "^2.0.0",
"hast-to-hyperscript": "^9.0.0",
"lodash.uniq": "^4.5.0",
"mdast-util-to-hast": "^10.1.0",
"recast": "^0.20.4",
"recast": "^0.20.0",
"remark-mdx": "^2.0.0-next.8",
"remark-parse": "9.0.0",
"remark-squeeze-paragraphs": "4.0.0",
"remark-parse": "^9.0.0",
"remark-squeeze-paragraphs": "^4.0.0",
"stringify-entities": "^3.1.0",
"unified": "9.0.0",
"unist-builder": "2.0.3"
"unified": "^9.0.0",
"unist-builder": "^2.0.0"
},
"devDependencies": {
"remark-footnotes": "3.0.0",
"remark-gfm": "1.0.0",
"remark-footnotes": "^3.0.0",
"remark-gfm": "^1.0.0",
"rehype-katex": "^4.0.0",
"remark-math": "^4.0.0"
},
Expand Down
10 changes: 5 additions & 5 deletions packages/remark-mdx/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ test('parse', function (t) {

t.test('MDX vs. MDX.js', function (t) {
t.deepEqual(
clean(unified().use(parse).use(mdx, {js: false}).parse('{1 + /* } */ 2}').children[0]),
u('paragraph', [
u('mdxTextExpression', '1 + /* '),
u('text', ' */ 2}')
]),
clean(
unified().use(parse).use(mdx, {js: false}).parse('{1 + /* } */ 2}')
.children[0]
),
u('paragraph', [u('mdxTextExpression', '1 + /* '), u('text', ' */ 2}')]),
'should count braces in agnostic mode (`js: false`)'
)

Expand Down
1 change: 1 addition & 0 deletions packages/vue-loader/test/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const {mount} = require('@vue/test-utils')
const vueMergeProps = require('babel-helper-vue-jsx-merge-props')
const {mdx} = require('../../vue')

// See `loader`’s tests for how to upgrade these to webpack 5.
const transform = (filePath, options) => {
return new Promise((resolve, reject) => {
const compiler = webpack({
Expand Down
Loading

0 comments on commit e679f4e

Please sign in to comment.