@startupjs/bundler 0.60.0-canary.9 → 0.61.2
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 +25 -1
- package/metro-config.js +6 -1
- package/package.json +6 -6
- package/lib/startupjsLoader.js +0 -27
package/lib/mdxLoader.js
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
const remarkGfm = require('remark-gfm').default
|
|
2
2
|
const { compileSync } = require('@mdx-js/mdx')
|
|
3
|
+
const { readFileSync } = require('fs')
|
|
4
|
+
const path = require('path')
|
|
5
|
+
|
|
6
|
+
const OLD_MDX_IMPORT = '@startupjs/mdx/useMDXComponents'
|
|
7
|
+
const MDX_IMPORT = '@startupjs-ui/mdx'
|
|
3
8
|
|
|
4
9
|
module.exports = function getMDXLoader (source) {
|
|
5
10
|
try {
|
|
6
11
|
source = compileSync(source, {
|
|
7
|
-
providerImportSource:
|
|
12
|
+
providerImportSource: getMDXComponentsImport(),
|
|
8
13
|
remarkPlugins: [remarkGfm],
|
|
9
14
|
jsx: true
|
|
10
15
|
}).value
|
|
@@ -16,3 +21,22 @@ module.exports = function getMDXLoader (source) {
|
|
|
16
21
|
}
|
|
17
22
|
return source
|
|
18
23
|
}
|
|
24
|
+
|
|
25
|
+
let mdxComponentsImport
|
|
26
|
+
// check if the project's package.json has an old @startupjs/ui dependency
|
|
27
|
+
// and use old mdx library in this case for backward compatibility
|
|
28
|
+
function getMDXComponentsImport () {
|
|
29
|
+
if (mdxComponentsImport) return mdxComponentsImport
|
|
30
|
+
let hasOldStartupUi = false
|
|
31
|
+
try {
|
|
32
|
+
const projectPkgPath = path.join(process.cwd(), 'package.json')
|
|
33
|
+
const packageJson = readFileSync(projectPkgPath, 'utf8')
|
|
34
|
+
if (/"@startupjs\/ui"/.test(packageJson)) hasOldStartupUi = true
|
|
35
|
+
} catch (err) {}
|
|
36
|
+
if (hasOldStartupUi) {
|
|
37
|
+
mdxComponentsImport = OLD_MDX_IMPORT
|
|
38
|
+
} else {
|
|
39
|
+
mdxComponentsImport = MDX_IMPORT
|
|
40
|
+
}
|
|
41
|
+
return mdxComponentsImport
|
|
42
|
+
}
|
package/metro-config.js
CHANGED
|
@@ -48,7 +48,12 @@ exports.getDefaultConfig = function getDefaultConfig (projectRoot, {
|
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
function isBuild () {
|
|
51
|
-
return
|
|
51
|
+
return (
|
|
52
|
+
process.env.IS_BUILD ||
|
|
53
|
+
process.env.CI ||
|
|
54
|
+
process.env.EAS_BUILD ||
|
|
55
|
+
(process.env.NODE_ENV === 'production' && !process.env.FORCE_SERVER)
|
|
56
|
+
)
|
|
52
57
|
}
|
|
53
58
|
|
|
54
59
|
function addServer (config) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startupjs/bundler",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.61.2",
|
|
4
4
|
"description": "Opinionated scripts and configs to develop a react-native-web project",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {
|
|
@@ -18,13 +18,13 @@
|
|
|
18
18
|
"@babel/core": "^7.9.0",
|
|
19
19
|
"@babel/plugin-syntax-jsx": "^7.0.0",
|
|
20
20
|
"@mdx-js/mdx": "^3.0.0",
|
|
21
|
-
"@startupjs/babel-plugin-eliminator": "^0.
|
|
22
|
-
"@startupjs/babel-plugin-startupjs-plugins": "^0.
|
|
23
|
-
"@startupjs/server": "^0.
|
|
21
|
+
"@startupjs/babel-plugin-eliminator": "^0.61.0",
|
|
22
|
+
"@startupjs/babel-plugin-startupjs-plugins": "^0.61.0",
|
|
23
|
+
"@startupjs/server": "^0.61.0",
|
|
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.
|
|
27
|
+
"babel-preset-startupjs": "^0.61.2",
|
|
28
28
|
"connect": "^3.7.0",
|
|
29
29
|
"lodash": "^4.17.20",
|
|
30
30
|
"remark-gfm": "4.0.1"
|
|
@@ -33,5 +33,5 @@
|
|
|
33
33
|
"cssxjs": "*",
|
|
34
34
|
"react-native-svg": "*"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "00533aa32f235351daadab676a87ca9db0252cbd"
|
|
37
37
|
}
|
package/lib/startupjsLoader.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
// Only used for React Native
|
|
2
|
-
const babel = require('@babel/core')
|
|
3
|
-
|
|
4
|
-
module.exports = function startupjsLoader (source) {
|
|
5
|
-
const filename = this.resourcePath
|
|
6
|
-
const platform = this.query.platform
|
|
7
|
-
|
|
8
|
-
// There is a bug in metro when BABEL_ENV is a string "undefined".
|
|
9
|
-
// We have to workaround it and use NODE_ENV.
|
|
10
|
-
const env = (process.env.BABEL_ENV !== 'undefined' && process.env.BABEL_ENV) || process.env.NODE_ENV
|
|
11
|
-
|
|
12
|
-
return babel.transformSync(source, {
|
|
13
|
-
filename,
|
|
14
|
-
babelrc: false,
|
|
15
|
-
configFile: false,
|
|
16
|
-
presets: [
|
|
17
|
-
[require('babel-preset-startupjs'), {
|
|
18
|
-
// in Program: state.file.opts.caller.platform when used in metro
|
|
19
|
-
// when used in metro - state.file.opts.caller.bundler === 'metro'
|
|
20
|
-
platform,
|
|
21
|
-
// in Program: state.file.opts.envName when used in metro
|
|
22
|
-
env
|
|
23
|
-
}],
|
|
24
|
-
[require('cssxjs/babel'), { platform }]
|
|
25
|
-
]
|
|
26
|
-
}).code
|
|
27
|
-
}
|