@startupjs/bundler 0.52.1 → 0.52.3
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/getMDXLoader.js +23 -0
- package/lib/rnTransformer.js +3 -2
- package/package.json +3 -3
- package/lib/mdxLoader.js +0 -11
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
}
|
package/lib/rnTransformer.js
CHANGED
|
@@ -6,10 +6,10 @@ const platformSingleton = require(
|
|
|
6
6
|
const stylusToCssLoader = require('./stylusToCssLoader')
|
|
7
7
|
const cssToReactNativeLoader = require('./cssToReactNativeLoader')
|
|
8
8
|
const mdxExamplesLoader = require('./mdxExamplesLoader')
|
|
9
|
-
const
|
|
9
|
+
const getMDXLoader = require('./getMDXLoader')
|
|
10
10
|
const callLoader = require('./callLoader')
|
|
11
11
|
|
|
12
|
-
module.exports.transform = function ({ src, filename, options = {} }) {
|
|
12
|
+
module.exports.transform = async function ({ src, filename, options = {} }) {
|
|
13
13
|
const { platform } = options
|
|
14
14
|
platformSingleton.value = platform
|
|
15
15
|
|
|
@@ -25,6 +25,7 @@ module.exports.transform = function ({ src, filename, options = {} }) {
|
|
|
25
25
|
} else if (/\.[cm]?jsx?$/.test(filename) && /['"]startupjs['"]/.test(src)) {
|
|
26
26
|
return upstreamTransformer.transform({ src, filename, options })
|
|
27
27
|
} else if (/\.mdx?$/.test(filename)) {
|
|
28
|
+
const mdxLoader = await getMDXLoader()
|
|
28
29
|
src = callLoader(mdxExamplesLoader, src, filename)
|
|
29
30
|
src = callLoader(mdxLoader, src, filename)
|
|
30
31
|
return upstreamTransformer.transform({ src, filename, options })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startupjs/bundler",
|
|
3
|
-
"version": "0.52.
|
|
3
|
+
"version": "0.52.3",
|
|
4
4
|
"description": "Opinionated scripts and configs to develop a react-native-web project",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"assets-webpack-plugin": "^7.1.1",
|
|
27
27
|
"autoprefixer": "^10.4.0",
|
|
28
28
|
"babel-loader": "^8.2.3",
|
|
29
|
-
"babel-preset-startupjs": "^0.52.
|
|
29
|
+
"babel-preset-startupjs": "^0.52.3",
|
|
30
30
|
"css-loader": "^6.5.0",
|
|
31
31
|
"css-minimizer-webpack-plugin": "^5.0.0",
|
|
32
32
|
"file-loader": "^6.2.0",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"react-native-svg": ">= 12.1.0"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "5e290f4bc00af285a0136e75af62fe323cb5f43c"
|
|
54
54
|
}
|
package/lib/mdxLoader.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const mdx = require('@mdx-js/mdx')
|
|
2
|
-
|
|
3
|
-
const DEFAULT_MDX_RENDERER = `
|
|
4
|
-
import { mdx } from '@mdx-js/react'
|
|
5
|
-
`
|
|
6
|
-
|
|
7
|
-
module.exports = function mdxLoader (source) {
|
|
8
|
-
source = mdx.sync(source)
|
|
9
|
-
source = DEFAULT_MDX_RENDERER + '\n' + source
|
|
10
|
-
return source
|
|
11
|
-
}
|