@startupjs/bundler 0.60.0-canary.7 → 0.60.0-canary.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/mdxLoader.js +18 -0
- package/metro-babel-transformer.js +1 -2
- package/package.json +5 -5
- package/lib/getMDXLoader.js +0 -23
package/lib/mdxLoader.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
const remarkGfm = require('remark-gfm').default
|
|
2
|
+
const { compileSync } = require('@mdx-js/mdx')
|
|
3
|
+
|
|
4
|
+
module.exports = function getMDXLoader (source) {
|
|
5
|
+
try {
|
|
6
|
+
source = compileSync(source, {
|
|
7
|
+
providerImportSource: '@startupjs/mdx/useMDXComponents',
|
|
8
|
+
remarkPlugins: [remarkGfm],
|
|
9
|
+
jsx: true
|
|
10
|
+
}).value
|
|
11
|
+
} catch (err) {
|
|
12
|
+
if (err) {
|
|
13
|
+
console.log('>> mdx compile error', err)
|
|
14
|
+
throw err
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
return source
|
|
18
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const stylusToCssLoader = require('cssxjs/loaders/stylusToCssLoader')
|
|
2
2
|
const cssToReactNativeLoader = require('cssxjs/loaders/cssToReactNativeLoader')
|
|
3
3
|
const mdxExamplesLoader = require('./lib/mdxExamplesLoader')
|
|
4
|
-
const
|
|
4
|
+
const mdxLoader = require('./lib/mdxLoader')
|
|
5
5
|
const callLoader = require('./lib/callLoader')
|
|
6
6
|
const asyncSvgLoader = require('./lib/asyncSvgLoader')
|
|
7
7
|
|
|
@@ -20,7 +20,6 @@ module.exports.transform = async function startupjsMetroBabelTransform ({
|
|
|
20
20
|
} else if (/\.svg$/.test(filename)) {
|
|
21
21
|
src = await callLoader(asyncSvgLoader, src, filename)
|
|
22
22
|
} else if (/\.mdx?$/.test(filename)) {
|
|
23
|
-
const mdxLoader = await getMDXLoader()
|
|
24
23
|
src = callLoader(mdxExamplesLoader, src, filename)
|
|
25
24
|
src = callLoader(mdxLoader, src, filename)
|
|
26
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startupjs/bundler",
|
|
3
|
-
"version": "0.60.0-canary.
|
|
3
|
+
"version": "0.60.0-canary.9",
|
|
4
4
|
"description": "Opinionated scripts and configs to develop a react-native-web project",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -17,21 +17,21 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@babel/core": "^7.9.0",
|
|
19
19
|
"@babel/plugin-syntax-jsx": "^7.0.0",
|
|
20
|
-
"@mdx-js/mdx": "^
|
|
20
|
+
"@mdx-js/mdx": "^3.0.0",
|
|
21
21
|
"@startupjs/babel-plugin-eliminator": "^0.60.0-canary.7",
|
|
22
22
|
"@startupjs/babel-plugin-startupjs-plugins": "^0.60.0-canary.7",
|
|
23
23
|
"@startupjs/server": "^0.60.0-canary.7",
|
|
24
24
|
"@svgr/core": "^8.1.0",
|
|
25
25
|
"@svgr/plugin-jsx": "^8.1.0",
|
|
26
26
|
"@svgr/plugin-svgo": "^8.1.0",
|
|
27
|
-
"babel-preset-startupjs": "^0.60.0-canary.
|
|
27
|
+
"babel-preset-startupjs": "^0.60.0-canary.9",
|
|
28
28
|
"connect": "^3.7.0",
|
|
29
29
|
"lodash": "^4.17.20",
|
|
30
|
-
"remark-gfm": "
|
|
30
|
+
"remark-gfm": "4.0.1"
|
|
31
31
|
},
|
|
32
32
|
"peerDependencies": {
|
|
33
33
|
"cssxjs": "*",
|
|
34
34
|
"react-native-svg": "*"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "d314ca5e6c7b96f6692fb0eb31990eebab31566f"
|
|
37
37
|
}
|
package/lib/getMDXLoader.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const DEFAULT_MDX_RENDERER = `
|
|
2
|
-
import { mdx } from '@mdx-js/react'
|
|
3
|
-
`
|
|
4
|
-
const remarkGfm = require('remark-gfm')
|
|
5
|
-
|
|
6
|
-
module.exports = async function getMDXLoader () {
|
|
7
|
-
const mdx = await import('@mdx-js/mdx')
|
|
8
|
-
|
|
9
|
-
return (source) => {
|
|
10
|
-
source = mdx.compileSync(source, {
|
|
11
|
-
providerImportSource: '@startupjs/mdx/client/MDXProvider/index.js',
|
|
12
|
-
remarkPlugins: [remarkGfm]
|
|
13
|
-
})
|
|
14
|
-
source = DEFAULT_MDX_RENDERER + '\n' + source
|
|
15
|
-
// To make mdx works, we should remove somehow the \n character child
|
|
16
|
-
// from the children of MDXContent in the output source.
|
|
17
|
-
// MDX v2 has made some changes in how it handles newlines and whitespace
|
|
18
|
-
// compared to MDX v1. In MDX v1 newline are not inclided in the output,
|
|
19
|
-
// but in MDX v2 it included.
|
|
20
|
-
// console.log(source)
|
|
21
|
-
return source
|
|
22
|
-
}
|
|
23
|
-
}
|