Skip to content

Commit

Permalink
feat(rn): udpate metro & @react-native-community/cli version (#9540)
Browse files Browse the repository at this point in the history
* feat(rn): udpate metro & @react-native-community/cli version

* feat(rn-runner): add sourcemap options support
  • Loading branch information
zhiqingchen authored Jun 16, 2021
1 parent aad5238 commit c0fb538
Show file tree
Hide file tree
Showing 10 changed files with 957 additions and 1,691 deletions.
2 changes: 1 addition & 1 deletion packages/babel-preset-taro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"babel-plugin-transform-react-jsx-to-rn-stylesheet": "3.2.12",
"babel-plugin-transform-taroapi": "3.2.12",
"core-js": "^3.6.5",
"metro-react-native-babel-preset": "^0.63.0",
"metro-react-native-babel-preset": "^0.64.0",
"react-refresh": "0.9.0"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions packages/babel-preset-taro/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1275,10 +1275,10 @@ lodash.debounce@^4.0.8:
resolved "https://registry.npm.taobao.org/lodash.debounce/download/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
integrity sha1-gteb/zCmfEAF/9XiUVMArZyk168=

metro-react-native-babel-preset@^0.63.0:
version "0.63.0"
resolved "https://registry.nlark.com/metro-react-native-babel-preset/download/metro-react-native-babel-preset-0.63.0.tgz?cache=0&sync_timestamp=1618912791098&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fmetro-react-native-babel-preset%2Fdownload%2Fmetro-react-native-babel-preset-0.63.0.tgz#bc67d4d251ac72f30b7f3d92a069aea825577751"
integrity sha1-vGfU0lGscvMLfz2SoGmuqCVXd1E=
metro-react-native-babel-preset@^0.64.0:
version "0.64.0"
resolved "https://registry.yarnpkg.com/metro-react-native-babel-preset/-/metro-react-native-babel-preset-0.64.0.tgz#76861408681dfda3c1d962eb31a8994918c976f8"
integrity sha512-HcZ0RWQRuJfpPiaHyFQJzcym+/dDIVUPwUAXWoub/C4GkGu+mPjp8vqK6g0FxokCnnI2TK0gZTza2IDfiNNscQ==
dependencies:
"@babel/core" "^7.0.0"
"@babel/plugin-proposal-class-properties" "^7.0.0"
Expand Down
2 changes: 1 addition & 1 deletion packages/taro-components-rn/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"expo-constants": "~9.2.0",
"expo-file-system": "~9.2.0",
"jest-expo": "^39.0.0",
"metro-react-native-babel-preset": "^0.65.2",
"metro-react-native-babel-preset": "^0.64.0",
"pre-commit": "^1.2.2",
"react-native": "^0.64.0",
"react-native-mock-render": "^0.1.9",
Expand Down
54 changes: 4 additions & 50 deletions packages/taro-components-rn/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@
dependencies:
"@babel/helper-plugin-utils" "^7.13.0"

"@babel/plugin-transform-async-to-generator@^7.0.0", "@babel/plugin-transform-async-to-generator@^7.12.13":
"@babel/plugin-transform-async-to-generator@^7.12.13":
version "7.13.0"
resolved "https://registry.npm.taobao.org/@babel/plugin-transform-async-to-generator/download/@babel/plugin-transform-async-to-generator-7.13.0.tgz#8e112bf6771b82bf1e974e5e26806c5c99aa516f"
integrity sha1-jhEr9ncbgr8el05eJoBsXJmqUW8=
Expand Down Expand Up @@ -5385,10 +5385,10 @@ [email protected]:
dependencies:
uglify-es "^3.1.9"

[email protected]:
[email protected], metro-react-native-babel-preset@^0.64.0:
version "0.64.0"
resolved "https://registry.nlark.com/metro-react-native-babel-preset/download/metro-react-native-babel-preset-0.64.0.tgz?cache=0&sync_timestamp=1618912791098&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fmetro-react-native-babel-preset%2Fdownload%2Fmetro-react-native-babel-preset-0.64.0.tgz#76861408681dfda3c1d962eb31a8994918c976f8"
integrity sha1-doYUCGgd/aPB2WLrMaiZSRjJdvg=
resolved "https://registry.yarnpkg.com/metro-react-native-babel-preset/-/metro-react-native-babel-preset-0.64.0.tgz#76861408681dfda3c1d962eb31a8994918c976f8"
integrity sha512-HcZ0RWQRuJfpPiaHyFQJzcym+/dDIVUPwUAXWoub/C4GkGu+mPjp8vqK6g0FxokCnnI2TK0gZTza2IDfiNNscQ==
dependencies:
"@babel/core" "^7.0.0"
"@babel/plugin-proposal-class-properties" "^7.0.0"
Expand Down Expand Up @@ -5430,52 +5430,6 @@ [email protected]:
"@babel/template" "^7.0.0"
react-refresh "^0.4.0"

metro-react-native-babel-preset@^0.65.2:
version "0.65.2"
resolved "https://registry.nlark.com/metro-react-native-babel-preset/download/metro-react-native-babel-preset-0.65.2.tgz?cache=0&sync_timestamp=1618912791098&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fmetro-react-native-babel-preset%2Fdownload%2Fmetro-react-native-babel-preset-0.65.2.tgz#786cbb8b21daa614cbbebcc5c3ce72b6b0710892"
integrity sha1-eGy7iyHaphTLvrzFw85ytrBxCJI=
dependencies:
"@babel/core" "^7.0.0"
"@babel/plugin-proposal-class-properties" "^7.0.0"
"@babel/plugin-proposal-export-default-from" "^7.0.0"
"@babel/plugin-proposal-nullish-coalescing-operator" "^7.0.0"
"@babel/plugin-proposal-object-rest-spread" "^7.0.0"
"@babel/plugin-proposal-optional-catch-binding" "^7.0.0"
"@babel/plugin-proposal-optional-chaining" "^7.0.0"
"@babel/plugin-syntax-dynamic-import" "^7.0.0"
"@babel/plugin-syntax-export-default-from" "^7.0.0"
"@babel/plugin-syntax-flow" "^7.2.0"
"@babel/plugin-syntax-nullish-coalescing-operator" "^7.0.0"
"@babel/plugin-syntax-optional-chaining" "^7.0.0"
"@babel/plugin-transform-arrow-functions" "^7.0.0"
"@babel/plugin-transform-async-to-generator" "^7.0.0"
"@babel/plugin-transform-block-scoping" "^7.0.0"
"@babel/plugin-transform-classes" "^7.0.0"
"@babel/plugin-transform-computed-properties" "^7.0.0"
"@babel/plugin-transform-destructuring" "^7.0.0"
"@babel/plugin-transform-exponentiation-operator" "^7.0.0"
"@babel/plugin-transform-flow-strip-types" "^7.0.0"
"@babel/plugin-transform-for-of" "^7.0.0"
"@babel/plugin-transform-function-name" "^7.0.0"
"@babel/plugin-transform-literals" "^7.0.0"
"@babel/plugin-transform-modules-commonjs" "^7.0.0"
"@babel/plugin-transform-object-assign" "^7.0.0"
"@babel/plugin-transform-parameters" "^7.0.0"
"@babel/plugin-transform-react-display-name" "^7.0.0"
"@babel/plugin-transform-react-jsx" "^7.0.0"
"@babel/plugin-transform-react-jsx-self" "^7.0.0"
"@babel/plugin-transform-react-jsx-source" "^7.0.0"
"@babel/plugin-transform-regenerator" "^7.0.0"
"@babel/plugin-transform-runtime" "^7.0.0"
"@babel/plugin-transform-shorthand-properties" "^7.0.0"
"@babel/plugin-transform-spread" "^7.0.0"
"@babel/plugin-transform-sticky-regex" "^7.0.0"
"@babel/plugin-transform-template-literals" "^7.0.0"
"@babel/plugin-transform-typescript" "^7.5.0"
"@babel/plugin-transform-unicode-regex" "^7.0.0"
"@babel/template" "^7.0.0"
react-refresh "^0.4.0"

[email protected], metro-react-native-babel-transformer@^0.64.0:
version "0.64.0"
resolved "https://registry.nlark.com/metro-react-native-babel-transformer/download/metro-react-native-babel-transformer-0.64.0.tgz?cache=0&sync_timestamp=1618913443014&other_urls=https%3A%2F%2Fregistry.nlark.com%2Fmetro-react-native-babel-transformer%2Fdownload%2Fmetro-react-native-babel-transformer-0.64.0.tgz#eafef756972f20efdc51bd5361d55f8598355623"
Expand Down
16 changes: 8 additions & 8 deletions packages/taro-rn-runner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,19 @@
"npm": ">=6.0.0"
},
"dependencies": {
"@react-native-community/cli": "^4.13.1",
"@react-native-community/cli-server-api": "^4.13.1",
"@react-native-community/cli": "^5.0.1",
"@react-native-community/cli-server-api": "^5.0.1",
"@tarojs/helper": "3.2.12",
"@tarojs/rn-style-transformer": "3.2.12",
"@tarojs/rn-supporter": "3.2.12",
"@tarojs/rn-transformer": "3.2.12",
"fs-extra": "^9.0.1",
"lodash": "^4.17.4",
"metro": "^0.58.0",
"metro-cache": "^0.58.0",
"metro-config": "^0.58.0",
"metro-core": "^0.58.0",
"metro-react-native-babel-transformer": "^0.58.0",
"metro-resolver": "^0.58.0"
"metro": "^0.64.0",
"metro-cache": "^0.64.0",
"metro-config": "^0.64.0",
"metro-core": "^0.64.0",
"metro-react-native-babel-transformer": "^0.64.0",
"metro-resolver": "^0.64.0"
}
}
23 changes: 23 additions & 0 deletions packages/taro-rn-runner/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,25 @@ function concatOutputAssetsDest (config: any): string | undefined {
return res
}

function getOutputSourceMapOption (config: any): Record<string, any> {
if (!config?.deviceType || !config?.output) {
return {}
}
if (config.deviceType === 'ios') {
return {
sourceMapUrl: config.output.iosSourceMapUrl,
sourcemapOutput: config.output.iosSourcemapOutput,
sourcemapSourcesRoot: config.output.iosSourcemapSourcesRoot
}
} else {
return {
sourceMapUrl: config.output.androidSourceMapUrl,
sourcemapOutput: config.output.androidSourcemapOutput,
sourcemapSourcesRoot: config.output.androidSourcemapSourcesRoot
}
}
}

// TODO: 返回值
// HttpServer | {code: string, map: string}
// IBuildConfig
Expand Down Expand Up @@ -152,16 +171,20 @@ export default async function build (appPath: string, config: any): Promise<any>

const server = new Server(metroConfig)

const sourceMapOption = getOutputSourceMapOption(config)

try {
const requestOptions = {
...commonOptions,
...sourceMapOption,
entryFile: options.entry,
inlineSourceMap: false,
createModuleIdFactory: metroConfig.serializer.createModuleIdFactory
}
const bundle = await outputBundle.build(server, requestOptions)
const outputOptions = {
...commonOptions,
...sourceMapOption,
bundleOutput: options.out
}
await outputBundle.save(bundle, outputOptions, console.log)
Expand Down
Loading

0 comments on commit c0fb538

Please sign in to comment.