@expo/cli 0.17.1 → 0.17.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/build/bin/cli +2 -2
- package/build/src/prebuild/resolveTemplate.js +26 -9
- package/build/src/prebuild/resolveTemplate.js.map +1 -1
- package/build/src/start/interface/interactiveActions.js +1 -1
- package/build/src/start/interface/interactiveActions.js.map +1 -1
- package/build/src/start/server/getStaticRenderFunctions.js +65 -15
- package/build/src/start/server/getStaticRenderFunctions.js.map +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js +1 -1
- package/build/src/start/server/metro/MetroBundlerDevServer.js.map +1 -1
- package/build/src/start/server/metro/bundleApiRoutes.js.map +1 -1
- package/build/src/start/server/metro/createServerRouteMiddleware.js +3 -2
- package/build/src/start/server/metro/createServerRouteMiddleware.js.map +1 -1
- package/build/src/start/server/metro/metroErrorInterface.js +8 -2
- package/build/src/start/server/metro/metroErrorInterface.js.map +1 -1
- package/build/src/start/server/middleware/metroOptions.js +6 -3
- package/build/src/start/server/middleware/metroOptions.js.map +1 -1
- package/build/src/utils/analytics/rudderstackClient.js +2 -2
- package/build/src/utils/createFileTransform.js +12 -0
- package/build/src/utils/createFileTransform.js.map +1 -1
- package/build/src/utils/npm.js +2 -1
- package/build/src/utils/npm.js.map +1 -1
- package/package.json +6 -3
package/build/bin/cli
CHANGED
|
@@ -137,7 +137,7 @@ const args = (0, _arg).default({
|
|
|
137
137
|
});
|
|
138
138
|
if (args["--version"]) {
|
|
139
139
|
// Version is added in the build script.
|
|
140
|
-
console.log("0.17.
|
|
140
|
+
console.log("0.17.2");
|
|
141
141
|
process.exit(0);
|
|
142
142
|
}
|
|
143
143
|
if (args["--non-interactive"]) {
|
|
@@ -272,7 +272,7 @@ commands[command]().then((exec)=>{
|
|
|
272
272
|
logEventAsync("action", {
|
|
273
273
|
action: `expo ${command}`,
|
|
274
274
|
source: "expo/cli",
|
|
275
|
-
source_version: "0.17.
|
|
275
|
+
source_version: "0.17.2"
|
|
276
276
|
});
|
|
277
277
|
}
|
|
278
278
|
});
|
|
@@ -11,6 +11,7 @@ var _path = _interopRequireDefault(require("path"));
|
|
|
11
11
|
var _semver = _interopRequireDefault(require("semver"));
|
|
12
12
|
var _client = require("../api/rest/client");
|
|
13
13
|
var Log = _interopRequireWildcard(require("../log"));
|
|
14
|
+
var _createFileTransform = require("../utils/createFileTransform");
|
|
14
15
|
var _errors = require("../utils/errors");
|
|
15
16
|
var _npm = require("../utils/npm");
|
|
16
17
|
var _url = require("../utils/url");
|
|
@@ -95,18 +96,31 @@ function hasRepo({ username , name , branch , filePath }) {
|
|
|
95
96
|
const packagePath = `${filePath ? `/${filePath}` : ""}/package.json`;
|
|
96
97
|
return (0, _url).isUrlOk(contentsUrl + packagePath + `?ref=${branch}`);
|
|
97
98
|
}
|
|
98
|
-
async function downloadAndExtractRepoAsync(
|
|
99
|
-
const projectName = _path.default.basename(root);
|
|
100
|
-
const strip = filePath ? filePath.split("/").length + 1 : 1;
|
|
99
|
+
async function downloadAndExtractRepoAsync({ username , name , branch , filePath }, props) {
|
|
101
100
|
const url = `https://codeload.github.com/${username}/${name}/tar.gz/${branch}`;
|
|
102
101
|
debug("Downloading tarball from:", url);
|
|
102
|
+
// Extract the (sub)directory into non-empty path segments
|
|
103
|
+
const directory = filePath.replace(/^\//, "").split("/").filter(Boolean);
|
|
104
|
+
// Remove the (sub)directory paths, and the root folder added by GitHub
|
|
105
|
+
const strip = directory.length + 1;
|
|
106
|
+
// Only extract the relevant (sub)directories, ignoring irrelevant files
|
|
107
|
+
// The filder auto-ignores dotfiles, unless explicitly included
|
|
108
|
+
const filter = (0, _createFileTransform).createGlobFilter(!directory.length ? [
|
|
109
|
+
"*/**",
|
|
110
|
+
"*/ios/.xcode.env"
|
|
111
|
+
] : [
|
|
112
|
+
`*/${directory.join("/")}/**`,
|
|
113
|
+
`*/${directory.join("/")}/ios/.xcode.env`
|
|
114
|
+
], {
|
|
115
|
+
// Always ignore the `.xcworkspace` folder
|
|
116
|
+
ignore: [
|
|
117
|
+
"**/ios/*.xcworkspace/**"
|
|
118
|
+
]
|
|
119
|
+
});
|
|
103
120
|
return await (0, _npm).extractNpmTarballFromUrlAsync(url, {
|
|
104
|
-
|
|
105
|
-
name: projectName,
|
|
121
|
+
...props,
|
|
106
122
|
strip,
|
|
107
|
-
|
|
108
|
-
`${name}-${branch}${filePath ? `/${filePath}` : ""}`
|
|
109
|
-
]
|
|
123
|
+
filter
|
|
110
124
|
});
|
|
111
125
|
}
|
|
112
126
|
async function resolveTemplateArgAsync(templateDirectory, oraInstance, appName, template, templatePath) {
|
|
@@ -150,7 +164,10 @@ async function resolveTemplateArgAsync(templateDirectory, oraInstance, appName,
|
|
|
150
164
|
throw new _errors.AbortCommandError();
|
|
151
165
|
}
|
|
152
166
|
oraInstance.text = _chalk.default.bold(`Downloading files from repo ${_chalk.default.cyan(template)}. This might take a moment.`);
|
|
153
|
-
return await downloadAndExtractRepoAsync(
|
|
167
|
+
return await downloadAndExtractRepoAsync(repoInfo, {
|
|
168
|
+
cwd: templateDirectory,
|
|
169
|
+
name: appName
|
|
170
|
+
});
|
|
154
171
|
}
|
|
155
172
|
|
|
156
173
|
//# sourceMappingURL=resolveTemplate.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/prebuild/resolveTemplate.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport { Ora } from 'ora';\nimport path from 'path';\nimport semver from 'semver';\n\nimport { fetchAsync } from '../api/rest/client';\nimport * as Log from '../log';\nimport { AbortCommandError, CommandError } from '../utils/errors';\nimport {\n downloadAndExtractNpmModuleAsync,\n extractLocalNpmTarballAsync,\n extractNpmTarballFromUrlAsync,\n} from '../utils/npm';\nimport { isUrlOk } from '../utils/url';\n\nconst debug = require('debug')('expo:prebuild:resolveTemplate') as typeof console.log;\n\ntype RepoInfo = {\n username: string;\n name: string;\n branch: string;\n filePath: string;\n};\n\nexport async function cloneTemplateAsync({\n templateDirectory,\n template,\n exp,\n ora,\n}: {\n templateDirectory: string;\n template?: string;\n exp: Pick<ExpoConfig, 'name' | 'sdkVersion'>;\n ora: Ora;\n}): Promise<string> {\n if (template) {\n return await resolveTemplateArgAsync(templateDirectory, ora, exp.name, template);\n } else {\n const templatePackageName = await getTemplateNpmPackageName(exp.sdkVersion);\n return await downloadAndExtractNpmModuleAsync(templatePackageName, {\n cwd: templateDirectory,\n name: exp.name,\n });\n }\n}\n\n/** Given an `sdkVersion` like `44.0.0` return a fully qualified NPM package name like: `expo-template-bare-minimum@sdk-44` */\nfunction getTemplateNpmPackageName(sdkVersion?: string): string {\n // When undefined or UNVERSIONED, we use the latest version.\n if (!sdkVersion || sdkVersion === 'UNVERSIONED') {\n Log.log('Using an unspecified Expo SDK version. The latest template will be used.');\n return `expo-template-bare-minimum@latest`;\n }\n return `expo-template-bare-minimum@sdk-${semver.major(sdkVersion)}`;\n}\n\nasync function getRepoInfo(url: any, examplePath?: string): Promise<RepoInfo | undefined> {\n const [, username, name, t, _branch, ...file] = url.pathname.split('/');\n const filePath = examplePath ? examplePath.replace(/^\\//, '') : file.join('/');\n\n // Support repos whose entire purpose is to be an example, e.g.\n // https://github.com/:username/:my-cool-example-repo-name.\n if (t === undefined) {\n const infoResponse = await fetchAsync(`https://api.github.com/repos/${username}/${name}`);\n if (infoResponse.status !== 200) {\n return;\n }\n const info = await infoResponse.json();\n return { username, name, branch: info['default_branch'], filePath };\n }\n\n // If examplePath is available, the branch name takes the entire path\n const branch = examplePath\n ? `${_branch}/${file.join('/')}`.replace(new RegExp(`/${filePath}|/$`), '')\n : _branch;\n\n if (username && name && branch && t === 'tree') {\n return { username, name, branch, filePath };\n }\n return undefined;\n}\n\nfunction hasRepo({ username, name, branch, filePath }: RepoInfo) {\n const contentsUrl = `https://api.github.com/repos/${username}/${name}/contents`;\n const packagePath = `${filePath ? `/${filePath}` : ''}/package.json`;\n\n return isUrlOk(contentsUrl + packagePath + `?ref=${branch}`);\n}\n\nasync function downloadAndExtractRepoAsync(\n root: string,\n { username, name, branch, filePath }: RepoInfo\n): Promise<string> {\n const projectName = path.basename(root);\n\n const strip = filePath ? filePath.split('/').length + 1 : 1;\n\n const url = `https://codeload.github.com/${username}/${name}/tar.gz/${branch}`;\n debug('Downloading tarball from:', url);\n return await extractNpmTarballFromUrlAsync(url, {\n cwd: root,\n name: projectName,\n strip,\n fileList: [`${name}-${branch}${filePath ? `/${filePath}` : ''}`],\n });\n}\n\nexport async function resolveTemplateArgAsync(\n templateDirectory: string,\n oraInstance: Ora,\n appName: string,\n template: string,\n templatePath?: string\n): Promise<string> {\n assert(template, 'template is required');\n\n let repoUrl: URL | undefined;\n\n try {\n repoUrl = new URL(template);\n } catch (error: any) {\n if (error.code !== 'ERR_INVALID_URL') {\n oraInstance.fail(error);\n throw error;\n }\n }\n\n // On Windows, we can actually create a URL from a local path\n // Double-check if the created URL is not a path to avoid mixing up URLs and paths\n if (process.platform === 'win32' && repoUrl && path.isAbsolute(repoUrl.toString())) {\n repoUrl = undefined;\n }\n\n if (!repoUrl) {\n const templatePath = path.resolve(template);\n if (!fs.existsSync(templatePath)) {\n throw new CommandError(`template file does not exist: ${templatePath}`);\n }\n\n return await extractLocalNpmTarballAsync(templatePath, {\n cwd: templateDirectory,\n name: appName,\n });\n }\n\n if (repoUrl.origin !== 'https://github.com') {\n oraInstance.fail(\n `Invalid URL: ${chalk.red(\n `\"${template}\"`\n )}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n const repoInfo = await getRepoInfo(repoUrl, templatePath);\n\n if (!repoInfo) {\n oraInstance.fail(\n `Found invalid GitHub URL: ${chalk.red(`\"${template}\"`)}. Please fix the URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n const found = await hasRepo(repoInfo);\n\n if (!found) {\n oraInstance.fail(\n `Could not locate the repository for ${chalk.red(\n `\"${template}\"`\n )}. Please check that the repository exists and try again.`\n );\n throw new AbortCommandError();\n }\n\n oraInstance.text = chalk.bold(\n `Downloading files from repo ${chalk.cyan(template)}. This might take a moment.`\n );\n\n return await downloadAndExtractRepoAsync(templateDirectory, repoInfo);\n}\n"],"names":["cloneTemplateAsync","resolveTemplateArgAsync","Log","debug","require","templateDirectory","template","exp","ora","name","templatePackageName","getTemplateNpmPackageName","sdkVersion","downloadAndExtractNpmModuleAsync","cwd","log","semver","major","getRepoInfo","url","examplePath","username","t","_branch","file","pathname","split","filePath","replace","join","undefined","infoResponse","fetchAsync","status","info","json","branch","RegExp","hasRepo","contentsUrl","packagePath","isUrlOk","downloadAndExtractRepoAsync","root","projectName","path","basename","strip","length","extractNpmTarballFromUrlAsync","fileList","oraInstance","appName","templatePath","assert","repoUrl","URL","error","code","fail","process","platform","isAbsolute","toString","resolve","fs","existsSync","CommandError","extractLocalNpmTarballAsync","origin","chalk","red","AbortCommandError","repoInfo","found","text","bold","cyan"],"mappings":"AAAA;;;;QA2BsBA,kBAAkB,GAAlBA,kBAAkB;QAmFlBC,uBAAuB,GAAvBA,uBAAuB;AA7G1B,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACT,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAEF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACJ,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEA,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AACnCC,IAAAA,GAAG,mCAAM,QAAQ,EAAd;AACiC,IAAA,OAAiB,WAAjB,iBAAiB,CAAA;AAK1D,IAAA,IAAc,WAAd,cAAc,CAAA;AACG,IAAA,IAAc,WAAd,cAAc,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtC,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,+BAA+B,CAAC,AAAsB,AAAC;AAS/E,eAAeJ,kBAAkB,C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AAI,CAACoB,QAAQ,EAAE;QACbtB,WAAW,CAACQ,IAAI,CACd,CAAC,0BAA0B,EAAEW,MAAK,QAAA,CAACC,GAAG,CAAC,CAAC,CAAC,EAAEjE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,mCAAmC,CAAC,CAC7F,CAAC;QACF,MAAM,IAAIkE,OAAiB,kBAAA,EAAE,CAAC;KAC/B;IAED,MAAME,KAAK,GAAG,MAAMpC,OAAO,CAACmC,QAAQ,CAAC,AAAC;IAEtC,IAAI,CAACC,KAAK,EAAE;QACVvB,WAAW,CAACQ,IAAI,CACd,CAAC,oCAAoC,EAAEW,MAAK,QAAA,CAACC,GAAG,CAC9C,CAAC,CAAC,EAAEjE,QAAQ,CAAC,CAAC,CAAC,CAChB,CAAC,wDAAwD,CAAC,CAC5D,CAAC;QACF,MAAM,IAAIkE,OAAiB,kBAAA,EAAE,CAAC;KAC/B;IAEDrB,WAAW,CAACwB,IAAI,GAAGL,MAAK,QAAA,CAACM,IAAI,CAC3B,CAAC,4BAA4B,EAAEN,MAAK,QAAA,CAACO,IAAI,CAACvE,QAAQ,CAAC,CAAC,2BAA2B,CAAC,CACjF,CAAC;IAEF,OAAO,MAAMoC,2BAA2B,CAACrC,iBAAiB,EAAEoE,QAAQ,CAAC,CAAC;CACvE"}
|
|
1
|
+
{"version":3,"sources":["../../../src/prebuild/resolveTemplate.ts"],"sourcesContent":["import { ExpoConfig } from '@expo/config';\nimport assert from 'assert';\nimport chalk from 'chalk';\nimport fs from 'fs';\nimport { Ora } from 'ora';\nimport path from 'path';\nimport semver from 'semver';\n\nimport { fetchAsync } from '../api/rest/client';\nimport * as Log from '../log';\nimport { createGlobFilter } from '../utils/createFileTransform';\nimport { AbortCommandError, CommandError } from '../utils/errors';\nimport {\n ExtractProps,\n downloadAndExtractNpmModuleAsync,\n extractLocalNpmTarballAsync,\n extractNpmTarballFromUrlAsync,\n} from '../utils/npm';\nimport { isUrlOk } from '../utils/url';\n\nconst debug = require('debug')('expo:prebuild:resolveTemplate') as typeof console.log;\n\ntype RepoInfo = {\n username: string;\n name: string;\n branch: string;\n filePath: string;\n};\n\nexport async function cloneTemplateAsync({\n templateDirectory,\n template,\n exp,\n ora,\n}: {\n templateDirectory: string;\n template?: string;\n exp: Pick<ExpoConfig, 'name' | 'sdkVersion'>;\n ora: Ora;\n}): Promise<string> {\n if (template) {\n return await resolveTemplateArgAsync(templateDirectory, ora, exp.name, template);\n } else {\n const templatePackageName = await getTemplateNpmPackageName(exp.sdkVersion);\n return await downloadAndExtractNpmModuleAsync(templatePackageName, {\n cwd: templateDirectory,\n name: exp.name,\n });\n }\n}\n\n/** Given an `sdkVersion` like `44.0.0` return a fully qualified NPM package name like: `expo-template-bare-minimum@sdk-44` */\nfunction getTemplateNpmPackageName(sdkVersion?: string): string {\n // When undefined or UNVERSIONED, we use the latest version.\n if (!sdkVersion || sdkVersion === 'UNVERSIONED') {\n Log.log('Using an unspecified Expo SDK version. The latest template will be used.');\n return `expo-template-bare-minimum@latest`;\n }\n return `expo-template-bare-minimum@sdk-${semver.major(sdkVersion)}`;\n}\n\nasync function getRepoInfo(url: any, examplePath?: string): Promise<RepoInfo | undefined> {\n const [, username, name, t, _branch, ...file] = url.pathname.split('/');\n const filePath = examplePath ? examplePath.replace(/^\\//, '') : file.join('/');\n\n // Support repos whose entire purpose is to be an example, e.g.\n // https://github.com/:username/:my-cool-example-repo-name.\n if (t === undefined) {\n const infoResponse = await fetchAsync(`https://api.github.com/repos/${username}/${name}`);\n if (infoResponse.status !== 200) {\n return;\n }\n const info = await infoResponse.json();\n return { username, name, branch: info['default_branch'], filePath };\n }\n\n // If examplePath is available, the branch name takes the entire path\n const branch = examplePath\n ? `${_branch}/${file.join('/')}`.replace(new RegExp(`/${filePath}|/$`), '')\n : _branch;\n\n if (username && name && branch && t === 'tree') {\n return { username, name, branch, filePath };\n }\n return undefined;\n}\n\nfunction hasRepo({ username, name, branch, filePath }: RepoInfo) {\n const contentsUrl = `https://api.github.com/repos/${username}/${name}/contents`;\n const packagePath = `${filePath ? `/${filePath}` : ''}/package.json`;\n\n return isUrlOk(contentsUrl + packagePath + `?ref=${branch}`);\n}\n\nasync function downloadAndExtractRepoAsync(\n { username, name, branch, filePath }: RepoInfo,\n props: ExtractProps\n): Promise<string> {\n const url = `https://codeload.github.com/${username}/${name}/tar.gz/${branch}`;\n\n debug('Downloading tarball from:', url);\n\n // Extract the (sub)directory into non-empty path segments\n const directory = filePath.replace(/^\\//, '').split('/').filter(Boolean);\n // Remove the (sub)directory paths, and the root folder added by GitHub\n const strip = directory.length + 1;\n // Only extract the relevant (sub)directories, ignoring irrelevant files\n // The filder auto-ignores dotfiles, unless explicitly included\n const filter = createGlobFilter(\n !directory.length\n ? ['*/**', '*/ios/.xcode.env']\n : [`*/${directory.join('/')}/**`, `*/${directory.join('/')}/ios/.xcode.env`],\n {\n // Always ignore the `.xcworkspace` folder\n ignore: ['**/ios/*.xcworkspace/**'],\n }\n );\n\n return await extractNpmTarballFromUrlAsync(url, { ...props, strip, filter });\n}\n\nexport async function resolveTemplateArgAsync(\n templateDirectory: string,\n oraInstance: Ora,\n appName: string,\n template: string,\n templatePath?: string\n): Promise<string> {\n assert(template, 'template is required');\n\n let repoUrl: URL | undefined;\n\n try {\n repoUrl = new URL(template);\n } catch (error: any) {\n if (error.code !== 'ERR_INVALID_URL') {\n oraInstance.fail(error);\n throw error;\n }\n }\n\n // On Windows, we can actually create a URL from a local path\n // Double-check if the created URL is not a path to avoid mixing up URLs and paths\n if (process.platform === 'win32' && repoUrl && path.isAbsolute(repoUrl.toString())) {\n repoUrl = undefined;\n }\n\n if (!repoUrl) {\n const templatePath = path.resolve(template);\n if (!fs.existsSync(templatePath)) {\n throw new CommandError(`template file does not exist: ${templatePath}`);\n }\n\n return await extractLocalNpmTarballAsync(templatePath, {\n cwd: templateDirectory,\n name: appName,\n });\n }\n\n if (repoUrl.origin !== 'https://github.com') {\n oraInstance.fail(\n `Invalid URL: ${chalk.red(\n `\"${template}\"`\n )}. Only GitHub repositories are supported. Please use a GitHub URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n const repoInfo = await getRepoInfo(repoUrl, templatePath);\n\n if (!repoInfo) {\n oraInstance.fail(\n `Found invalid GitHub URL: ${chalk.red(`\"${template}\"`)}. Please fix the URL and try again.`\n );\n throw new AbortCommandError();\n }\n\n const found = await hasRepo(repoInfo);\n\n if (!found) {\n oraInstance.fail(\n `Could not locate the repository for ${chalk.red(\n `\"${template}\"`\n )}. Please check that the repository exists and try again.`\n );\n throw new AbortCommandError();\n }\n\n oraInstance.text = chalk.bold(\n `Downloading files from repo ${chalk.cyan(template)}. This might take a moment.`\n );\n\n return await downloadAndExtractRepoAsync(repoInfo, {\n cwd: templateDirectory,\n name: appName,\n });\n}\n"],"names":["cloneTemplateAsync","resolveTemplateArgAsync","Log","debug","require","templateDirectory","template","exp","ora","name","templatePackageName","getTemplateNpmPackageName","sdkVersion","downloadAndExtractNpmModuleAsync","cwd","log","semver","major","getRepoInfo","url","examplePath","username","t","_branch","file","pathname","split","filePath","replace","join","undefined","infoResponse","fetchAsync","status","info","json","branch","RegExp","hasRepo","contentsUrl","packagePath","isUrlOk","downloadAndExtractRepoAsync","props","directory","filter","Boolean","strip","length","createGlobFilter","ignore","extractNpmTarballFromUrlAsync","oraInstance","appName","templatePath","assert","repoUrl","URL","error","code","fail","process","platform","path","isAbsolute","toString","resolve","fs","existsSync","CommandError","extractLocalNpmTarballAsync","origin","chalk","red","AbortCommandError","repoInfo","found","text","bold","cyan"],"mappings":"AAAA;;;;QA6BsBA,kBAAkB,GAAlBA,kBAAkB;QA4FlBC,uBAAuB,GAAvBA,uBAAuB;AAxH1B,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AACT,IAAA,MAAO,kCAAP,OAAO,EAAA;AACV,IAAA,GAAI,kCAAJ,IAAI,EAAA;AAEF,IAAA,KAAM,kCAAN,MAAM,EAAA;AACJ,IAAA,OAAQ,kCAAR,QAAQ,EAAA;AAEA,I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AK,QAAA,CAACM,IAAI,CAC3B,CAAC,4BAA4B,EAAEN,MAAK,QAAA,CAACO,IAAI,CAACzE,QAAQ,CAAC,CAAC,2BAA2B,CAAC,CACjF,CAAC;IAEF,OAAO,MAAMoC,2BAA2B,CAACiC,QAAQ,EAAE;QACjD7D,GAAG,EAAET,iBAAiB;QACtBI,IAAI,EAAE4C,OAAO;KACd,CAAC,CAAC;CACJ"}
|
|
@@ -149,7 +149,7 @@ class DevServerManagerActions {
|
|
|
149
149
|
{
|
|
150
150
|
title: "Open React devtools",
|
|
151
151
|
value: "openReactDevTools",
|
|
152
|
-
action: this.openReactDevToolsAsync
|
|
152
|
+
action: this.openReactDevToolsAsync.bind(this)
|
|
153
153
|
}
|
|
154
154
|
];
|
|
155
155
|
const pluginMenuItems = (await this.devServerManager.devtoolsPluginManager.queryPluginsAsync()).map((plugin)=>({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/interface/interactiveActions.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { BLT, printHelp, printItem, printQRCode, printUsage, StartOptions } from './commandsTable';\nimport * as Log from '../../log';\nimport { delayAsync } from '../../utils/delay';\nimport { learnMore } from '../../utils/link';\nimport { openBrowserAsync } from '../../utils/open';\nimport { ExpoChoice, selectAsync } from '../../utils/prompts';\nimport { DevServerManager } from '../server/DevServerManager';\nimport {\n addReactDevToolsReloadListener,\n startReactDevToolsProxyAsync,\n} from '../server/ReactDevToolsProxy';\nimport {\n MetroInspectorProxyApp,\n openJsInspector,\n queryAllInspectorAppsAsync,\n} from '../server/middleware/inspector/JsInspector';\n\nconst debug = require('debug')('expo:start:interface:interactiveActions') as typeof console.log;\n\ninterface MoreToolMenuItem extends ExpoChoice<string> {\n action?: () => unknown;\n}\n\n/** Wraps the DevServerManager and adds an interface for user actions. */\nexport class DevServerManagerActions {\n constructor(private devServerManager: DevServerManager) {}\n\n printDevServerInfo(\n options: Pick<StartOptions, 'devClient' | 'isWebSocketsEnabled' | 'platforms'>\n ) {\n // If native dev server is running, print its URL.\n if (this.devServerManager.getNativeDevServerPort()) {\n const devServer = this.devServerManager.getDefaultDevServer();\n try {\n const nativeRuntimeUrl = devServer.getNativeRuntimeUrl()!;\n const interstitialPageUrl = devServer.getRedirectUrl();\n\n printQRCode(interstitialPageUrl ?? nativeRuntimeUrl);\n\n if (interstitialPageUrl) {\n Log.log(\n printItem(\n chalk`Choose an app to open your project at {underline ${interstitialPageUrl}}`\n )\n );\n }\n Log.log(printItem(chalk`Metro waiting on {underline ${nativeRuntimeUrl}}`));\n if (options.devClient === false) {\n // TODO: if development build, change this message!\n Log.log(\n printItem('Scan the QR code above with Expo Go (Android) or the Camera app (iOS)')\n );\n } else {\n Log.log(\n printItem(\n 'Scan the QR code above to open the project in a development build. ' +\n learnMore('https://expo.fyi/start')\n )\n );\n }\n } catch (error) {\n console.log('err', error);\n // @ts-ignore: If there is no development build scheme, then skip the QR code.\n if (error.code !== 'NO_DEV_CLIENT_SCHEME') {\n throw error;\n } else {\n const serverUrl = devServer.getDevServerUrl();\n Log.log(printItem(chalk`Metro waiting on {underline ${serverUrl}}`));\n Log.log(printItem(`Linking is disabled because the client scheme cannot be resolved.`));\n }\n }\n }\n\n const webDevServer = this.devServerManager.getWebDevServer();\n const webUrl = webDevServer?.getDevServerUrl({ hostType: 'localhost' });\n if (webUrl) {\n Log.log();\n Log.log(printItem(chalk`Web is waiting on {underline ${webUrl}}`));\n }\n\n printUsage(options, { verbose: false });\n printHelp();\n Log.log();\n }\n\n async openJsInspectorAsync() {\n const metroServerOrigin = this.devServerManager.getDefaultDevServer().getJsInspectorBaseUrl();\n const apps = await queryAllInspectorAppsAsync(metroServerOrigin);\n let app: MetroInspectorProxyApp | null = null;\n\n if (!apps.length) {\n return Log.warn(\n chalk`{bold Debug:} No compatible apps connected. JavaScript Debugging can only be used with the Hermes engine. ${learnMore(\n 'https://docs.expo.dev/guides/using-hermes/'\n )}`\n );\n }\n\n if (apps.length === 1) {\n app = apps[0];\n } else {\n const choices = apps.map((app) => ({\n title: app.deviceName ?? 'Unknown device',\n value: app.id,\n app,\n }));\n\n const value = await selectAsync(chalk`Debug target {dim (Hermes only)}`, choices);\n const menuItem = choices.find((item) => item.value === value);\n if (!menuItem) {\n return Log.error(chalk`{bold Debug:} No device available for \"${value}\"`);\n }\n\n app = menuItem.app;\n }\n\n if (!app) {\n return Log.error(chalk`{bold Debug:} No device selected`);\n }\n\n try {\n await openJsInspector(metroServerOrigin, app);\n } catch (error: any) {\n Log.error('Failed to open JavaScript inspector. This is often an issue with Google Chrome.');\n Log.exception(error);\n }\n }\n\n reloadApp() {\n Log.log(`${BLT} Reloading apps`);\n // Send reload requests over the dev servers\n this.devServerManager.broadcastMessage('reload');\n }\n\n async openMoreToolsAsync() {\n // Options match: Chrome > View > Developer\n try {\n const defaultMenuItems: MoreToolMenuItem[] = [\n { title: 'Inspect elements', value: 'toggleElementInspector' },\n { title: 'Toggle performance monitor', value: 'togglePerformanceMonitor' },\n { title: 'Toggle developer menu', value: 'toggleDevMenu' },\n { title: 'Reload app', value: 'reload' },\n {\n title: 'Open React devtools',\n value: 'openReactDevTools',\n action: this.openReactDevToolsAsync,\n },\n // TODO: Maybe a \"View Source\" option to open code.\n ];\n const pluginMenuItems = (\n await this.devServerManager.devtoolsPluginManager.queryPluginsAsync()\n ).map((plugin) => ({\n title: chalk`Open devtools plugin - {bold ${plugin.packageName}}`,\n value: `devtoolsPlugin:${plugin.packageName}`,\n action: async () => {\n const url = new URL(\n plugin.webpageEndpoint,\n this.devServerManager\n .getDefaultDevServer()\n .getUrlCreator()\n .constructUrl({ scheme: 'http' })\n );\n await openBrowserAsync(url.toString());\n },\n }));\n const menuItems = [...defaultMenuItems, ...pluginMenuItems];\n const value = await selectAsync(chalk`Dev tools {dim (native only)}`, menuItems);\n const menuItem = menuItems.find((item) => item.value === value);\n if (menuItem?.action) {\n menuItem.action();\n } else if (menuItem?.value) {\n this.devServerManager.broadcastMessage('sendDevCommand', { name: menuItem.value });\n }\n } catch (error: any) {\n debug(error);\n // do nothing\n } finally {\n printHelp();\n }\n }\n\n async openReactDevToolsAsync() {\n await startReactDevToolsProxyAsync();\n const url = this.devServerManager.getDefaultDevServer().getReactDevToolsUrl();\n await openBrowserAsync(url);\n addReactDevToolsReloadListener(() => {\n this.reconnectReactDevTools();\n });\n this.reconnectReactDevTools();\n }\n\n async reconnectReactDevTools() {\n // Wait a little time for react-devtools to be initialized in browser\n await delayAsync(3000);\n this.devServerManager.broadcastMessage('sendDevCommand', { name: 'reconnectReactDevTools' });\n }\n\n toggleDevMenu() {\n Log.log(`${BLT} Toggling dev menu`);\n this.devServerManager.broadcastMessage('devMenu');\n }\n}\n"],"names":["Log","debug","require","DevServerManagerActions","constructor","devServerManager","printDevServerInfo","options","getNativeDevServerPort","devServer","getDefaultDevServer","nativeRuntimeUrl","getNativeRuntimeUrl","interstitialPageUrl","getRedirectUrl","printQRCode","log","printItem","chalk","devClient","learnMore","error","console","code","serverUrl","getDevServerUrl","webDevServer","getWebDevServer","webUrl","hostType","printUsage","verbose","printHelp","openJsInspectorAsync","metroServerOrigin","getJsInspectorBaseUrl","apps","queryAllInspectorAppsAsync","app","length","warn","choices","map","title","deviceName","value","id","selectAsync","menuItem","find","item","openJsInspector","exception","reloadApp","BLT","broadcastMessage","openMoreToolsAsync","defaultMenuItems","action","openReactDevToolsAsync","pluginMenuItems","devtoolsPluginManager","queryPluginsAsync","plugin","packageName","url","URL","webpageEndpoint","getUrlCreator","constructUrl","scheme","openBrowserAsync","toString","menuItems","name","startReactDevToolsProxyAsync","getReactDevToolsUrl","addReactDevToolsReloadListener","reconnectReactDevTools","delayAsync","toggleDevMenu"],"mappings":"AAAA;;;;AAAkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEwD,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;AACtFA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACY,IAAA,MAAmB,WAAnB,mBAAmB,CAAA;AACpB,IAA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G,CAAC,CAAC,EAAEsC,cAAG,IAAA,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACpC,IAAI,CAACjD,gBAAgB,CAACkD,gBAAgB,CAAC,SAAS,CAAC,CAAC;KACnD;CACF;QAjLYpD,uBAAuB,GAAvBA,uBAAuB"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/interface/interactiveActions.ts"],"sourcesContent":["import chalk from 'chalk';\n\nimport { BLT, printHelp, printItem, printQRCode, printUsage, StartOptions } from './commandsTable';\nimport * as Log from '../../log';\nimport { delayAsync } from '../../utils/delay';\nimport { learnMore } from '../../utils/link';\nimport { openBrowserAsync } from '../../utils/open';\nimport { ExpoChoice, selectAsync } from '../../utils/prompts';\nimport { DevServerManager } from '../server/DevServerManager';\nimport {\n addReactDevToolsReloadListener,\n startReactDevToolsProxyAsync,\n} from '../server/ReactDevToolsProxy';\nimport {\n MetroInspectorProxyApp,\n openJsInspector,\n queryAllInspectorAppsAsync,\n} from '../server/middleware/inspector/JsInspector';\n\nconst debug = require('debug')('expo:start:interface:interactiveActions') as typeof console.log;\n\ninterface MoreToolMenuItem extends ExpoChoice<string> {\n action?: () => unknown;\n}\n\n/** Wraps the DevServerManager and adds an interface for user actions. */\nexport class DevServerManagerActions {\n constructor(private devServerManager: DevServerManager) {}\n\n printDevServerInfo(\n options: Pick<StartOptions, 'devClient' | 'isWebSocketsEnabled' | 'platforms'>\n ) {\n // If native dev server is running, print its URL.\n if (this.devServerManager.getNativeDevServerPort()) {\n const devServer = this.devServerManager.getDefaultDevServer();\n try {\n const nativeRuntimeUrl = devServer.getNativeRuntimeUrl()!;\n const interstitialPageUrl = devServer.getRedirectUrl();\n\n printQRCode(interstitialPageUrl ?? nativeRuntimeUrl);\n\n if (interstitialPageUrl) {\n Log.log(\n printItem(\n chalk`Choose an app to open your project at {underline ${interstitialPageUrl}}`\n )\n );\n }\n Log.log(printItem(chalk`Metro waiting on {underline ${nativeRuntimeUrl}}`));\n if (options.devClient === false) {\n // TODO: if development build, change this message!\n Log.log(\n printItem('Scan the QR code above with Expo Go (Android) or the Camera app (iOS)')\n );\n } else {\n Log.log(\n printItem(\n 'Scan the QR code above to open the project in a development build. ' +\n learnMore('https://expo.fyi/start')\n )\n );\n }\n } catch (error) {\n console.log('err', error);\n // @ts-ignore: If there is no development build scheme, then skip the QR code.\n if (error.code !== 'NO_DEV_CLIENT_SCHEME') {\n throw error;\n } else {\n const serverUrl = devServer.getDevServerUrl();\n Log.log(printItem(chalk`Metro waiting on {underline ${serverUrl}}`));\n Log.log(printItem(`Linking is disabled because the client scheme cannot be resolved.`));\n }\n }\n }\n\n const webDevServer = this.devServerManager.getWebDevServer();\n const webUrl = webDevServer?.getDevServerUrl({ hostType: 'localhost' });\n if (webUrl) {\n Log.log();\n Log.log(printItem(chalk`Web is waiting on {underline ${webUrl}}`));\n }\n\n printUsage(options, { verbose: false });\n printHelp();\n Log.log();\n }\n\n async openJsInspectorAsync() {\n const metroServerOrigin = this.devServerManager.getDefaultDevServer().getJsInspectorBaseUrl();\n const apps = await queryAllInspectorAppsAsync(metroServerOrigin);\n let app: MetroInspectorProxyApp | null = null;\n\n if (!apps.length) {\n return Log.warn(\n chalk`{bold Debug:} No compatible apps connected. JavaScript Debugging can only be used with the Hermes engine. ${learnMore(\n 'https://docs.expo.dev/guides/using-hermes/'\n )}`\n );\n }\n\n if (apps.length === 1) {\n app = apps[0];\n } else {\n const choices = apps.map((app) => ({\n title: app.deviceName ?? 'Unknown device',\n value: app.id,\n app,\n }));\n\n const value = await selectAsync(chalk`Debug target {dim (Hermes only)}`, choices);\n const menuItem = choices.find((item) => item.value === value);\n if (!menuItem) {\n return Log.error(chalk`{bold Debug:} No device available for \"${value}\"`);\n }\n\n app = menuItem.app;\n }\n\n if (!app) {\n return Log.error(chalk`{bold Debug:} No device selected`);\n }\n\n try {\n await openJsInspector(metroServerOrigin, app);\n } catch (error: any) {\n Log.error('Failed to open JavaScript inspector. This is often an issue with Google Chrome.');\n Log.exception(error);\n }\n }\n\n reloadApp() {\n Log.log(`${BLT} Reloading apps`);\n // Send reload requests over the dev servers\n this.devServerManager.broadcastMessage('reload');\n }\n\n async openMoreToolsAsync() {\n // Options match: Chrome > View > Developer\n try {\n const defaultMenuItems: MoreToolMenuItem[] = [\n { title: 'Inspect elements', value: 'toggleElementInspector' },\n { title: 'Toggle performance monitor', value: 'togglePerformanceMonitor' },\n { title: 'Toggle developer menu', value: 'toggleDevMenu' },\n { title: 'Reload app', value: 'reload' },\n {\n title: 'Open React devtools',\n value: 'openReactDevTools',\n action: this.openReactDevToolsAsync.bind(this),\n },\n // TODO: Maybe a \"View Source\" option to open code.\n ];\n const pluginMenuItems = (\n await this.devServerManager.devtoolsPluginManager.queryPluginsAsync()\n ).map((plugin) => ({\n title: chalk`Open devtools plugin - {bold ${plugin.packageName}}`,\n value: `devtoolsPlugin:${plugin.packageName}`,\n action: async () => {\n const url = new URL(\n plugin.webpageEndpoint,\n this.devServerManager\n .getDefaultDevServer()\n .getUrlCreator()\n .constructUrl({ scheme: 'http' })\n );\n await openBrowserAsync(url.toString());\n },\n }));\n const menuItems = [...defaultMenuItems, ...pluginMenuItems];\n const value = await selectAsync(chalk`Dev tools {dim (native only)}`, menuItems);\n const menuItem = menuItems.find((item) => item.value === value);\n if (menuItem?.action) {\n menuItem.action();\n } else if (menuItem?.value) {\n this.devServerManager.broadcastMessage('sendDevCommand', { name: menuItem.value });\n }\n } catch (error: any) {\n debug(error);\n // do nothing\n } finally {\n printHelp();\n }\n }\n\n async openReactDevToolsAsync() {\n await startReactDevToolsProxyAsync();\n const url = this.devServerManager.getDefaultDevServer().getReactDevToolsUrl();\n await openBrowserAsync(url);\n addReactDevToolsReloadListener(() => {\n this.reconnectReactDevTools();\n });\n this.reconnectReactDevTools();\n }\n\n async reconnectReactDevTools() {\n // Wait a little time for react-devtools to be initialized in browser\n await delayAsync(3000);\n this.devServerManager.broadcastMessage('sendDevCommand', { name: 'reconnectReactDevTools' });\n }\n\n toggleDevMenu() {\n Log.log(`${BLT} Toggling dev menu`);\n this.devServerManager.broadcastMessage('devMenu');\n }\n}\n"],"names":["Log","debug","require","DevServerManagerActions","constructor","devServerManager","printDevServerInfo","options","getNativeDevServerPort","devServer","getDefaultDevServer","nativeRuntimeUrl","getNativeRuntimeUrl","interstitialPageUrl","getRedirectUrl","printQRCode","log","printItem","chalk","devClient","learnMore","error","console","code","serverUrl","getDevServerUrl","webDevServer","getWebDevServer","webUrl","hostType","printUsage","verbose","printHelp","openJsInspectorAsync","metroServerOrigin","getJsInspectorBaseUrl","apps","queryAllInspectorAppsAsync","app","length","warn","choices","map","title","deviceName","value","id","selectAsync","menuItem","find","item","openJsInspector","exception","reloadApp","BLT","broadcastMessage","openMoreToolsAsync","defaultMenuItems","action","openReactDevToolsAsync","bind","pluginMenuItems","devtoolsPluginManager","queryPluginsAsync","plugin","packageName","url","URL","webpageEndpoint","getUrlCreator","constructUrl","scheme","openBrowserAsync","toString","menuItems","name","startReactDevToolsProxyAsync","getReactDevToolsUrl","addReactDevToolsReloadListener","reconnectReactDevTools","delayAsync","toggleDevMenu"],"mappings":"AAAA;;;;AAAkB,IAAA,MAAO,kCAAP,OAAO,EAAA;AAEwD,IAAA,cAAiB,WAAjB,iBAAiB,CAAA;AACtFA,IAAAA,GAAG,mCAAM,WAAW,EAAjB;AACY,IAAA,MAAmB,WAAnB,mBAAmB,CAAA;AACpB,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;AACX,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;AACX,IAAA,QAAqB,WAArB,qBAAqB,CAAA;AAKtD,IAAA,mBAA8B,WAA9B,8BAA8B,CAAA;AAK9B,IAAA,YAA4C,WAA5C,4CAA4C,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEnD,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,yCAAyC,CAAC,AAAsB,AAAC;AAOzF,MAAMC,uBAAuB;IAClCC,YAAoBC,gBAAkC,CAAE;aAAp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,CAAC,CAAC;aACpF;SACF,CAAC,OAAOxB,KAAK,EAAO;YACnBpB,KAAK,CAACoB,KAAK,CAAC,CAAC;QACb,aAAa;SACd,QAAS;YACRW,CAAAA,GAAAA,cAAS,AAAE,CAAA,UAAF,EAAE,CAAC;SACb;KACF;IAED,MAAM2B,sBAAsB,GAAG;QAC7B,MAAMiB,CAAAA,GAAAA,mBAA4B,AAAE,CAAA,6BAAF,EAAE,CAAC;QACrC,MAAMV,GAAG,GAAG,IAAI,CAAC7D,gBAAgB,CAACK,mBAAmB,EAAE,CAACmE,mBAAmB,EAAE,AAAC;QAC9E,MAAML,CAAAA,GAAAA,KAAgB,AAAK,CAAA,iBAAL,CAACN,GAAG,CAAC,CAAC;QAC5BY,CAAAA,GAAAA,mBAA8B,AAE5B,CAAA,+BAF4B,CAAC,IAAM;YACnC,IAAI,CAACC,sBAAsB,EAAE,CAAC;SAC/B,CAAC,CAAC;QACH,IAAI,CAACA,sBAAsB,EAAE,CAAC;KAC/B;IAED,MAAMA,sBAAsB,GAAG;QAC7B,qEAAqE;QACrE,MAAMC,CAAAA,GAAAA,MAAU,AAAM,CAAA,WAAN,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,CAAC3E,gBAAgB,CAACkD,gBAAgB,CAAC,gBAAgB,EAAE;YAAEoB,IAAI,EAAE,wBAAwB;SAAE,CAAC,CAAC;KAC9F;IAEDM,aAAa,GAAG;QACdjF,GAAG,CAACgB,GAAG,CAAC,CAAC,EAAEsC,cAAG,IAAA,CAAC,kBAAkB,CAAC,CAAC,CAAC;QACpC,IAAI,CAACjD,gBAAgB,CAACkD,gBAAgB,CAAC,SAAS,CAAC,CAAC;KACnD;CACF;QAjLYpD,uBAAuB,GAAvBA,uBAAuB"}
|
|
@@ -23,7 +23,23 @@ function _interopRequireDefault(obj) {
|
|
|
23
23
|
default: obj
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
|
+
class MetroNodeError extends Error {
|
|
27
|
+
constructor(message, rawObject){
|
|
28
|
+
super(message);
|
|
29
|
+
this.rawObject = rawObject;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
26
32
|
const debug = require("debug")("expo:start:server:node-renderer");
|
|
33
|
+
const cachedSourceMaps = new Map();
|
|
34
|
+
// Support unhandled rejections
|
|
35
|
+
require("source-map-support").install({
|
|
36
|
+
retrieveSourceMap (source) {
|
|
37
|
+
if (cachedSourceMaps.has(source)) {
|
|
38
|
+
return cachedSourceMaps.get(source);
|
|
39
|
+
}
|
|
40
|
+
return null;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
27
43
|
function wrapBundle(str) {
|
|
28
44
|
// Skip the metro runtime so debugging is a bit easier.
|
|
29
45
|
// Replace the __r() call with an export statement.
|
|
@@ -101,18 +117,18 @@ async function createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFileP
|
|
|
101
117
|
baseUrl,
|
|
102
118
|
isExporting: true,
|
|
103
119
|
asyncRoutes: false,
|
|
104
|
-
routerRoot
|
|
120
|
+
routerRoot,
|
|
121
|
+
inlineSourceMap: false
|
|
105
122
|
});
|
|
106
|
-
|
|
123
|
+
let url;
|
|
124
|
+
if (devServerUrl) {
|
|
125
|
+
url = new URL(urlFragment.replace(/^\//, ""), devServerUrl).toString();
|
|
126
|
+
} else {
|
|
127
|
+
url = "/" + urlFragment.replace(/^\/+/, "");
|
|
128
|
+
}
|
|
107
129
|
debug("fetching from Metro:", root, serverPath, url);
|
|
108
130
|
return url;
|
|
109
131
|
}
|
|
110
|
-
class MetroNodeError extends Error {
|
|
111
|
-
constructor(message, rawObject){
|
|
112
|
-
super(message);
|
|
113
|
-
this.rawObject = rawObject;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
132
|
async function requireFileContentsWithMetro(projectRoot, devServerUrl, absoluteFilePath, props) {
|
|
117
133
|
const url = await createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFilePath, props);
|
|
118
134
|
const res = await (0, _nodeFetch).default(url);
|
|
@@ -130,14 +146,23 @@ async function requireFileContentsWithMetro(projectRoot, devServerUrl, absoluteF
|
|
|
130
146
|
throw new Error(`Error fetching bundle for static rendering: ${res.status} ${res.statusText}`);
|
|
131
147
|
}
|
|
132
148
|
const content = await res.text();
|
|
133
|
-
|
|
149
|
+
const map = await (0, _nodeFetch).default(url.replace(".bundle?", ".map?")).then((r)=>r.json()
|
|
150
|
+
);
|
|
151
|
+
cachedSourceMaps.set(url, {
|
|
152
|
+
url: projectRoot,
|
|
153
|
+
map
|
|
154
|
+
});
|
|
155
|
+
return {
|
|
156
|
+
src: wrapBundle(content),
|
|
157
|
+
filename: url
|
|
158
|
+
};
|
|
134
159
|
}
|
|
135
160
|
async function getStaticRenderFunctions(projectRoot, devServerUrl, options) {
|
|
136
|
-
const scriptContents = await getStaticRenderFunctionsContentAsync(projectRoot, devServerUrl, options);
|
|
137
|
-
return evalMetroAndWrapFunctions(projectRoot, scriptContents);
|
|
161
|
+
const { src: scriptContents , filename } = await getStaticRenderFunctionsContentAsync(projectRoot, devServerUrl, options);
|
|
162
|
+
return evalMetroAndWrapFunctions(projectRoot, scriptContents, filename);
|
|
138
163
|
}
|
|
139
|
-
function evalMetroAndWrapFunctions(projectRoot, script) {
|
|
140
|
-
const contents = evalMetro(script);
|
|
164
|
+
function evalMetroAndWrapFunctions(projectRoot, script, filename) {
|
|
165
|
+
const contents = evalMetro(projectRoot, script, filename);
|
|
141
166
|
// wrap each function with a try/catch that uses Metro's error formatter
|
|
142
167
|
return Object.keys(contents).reduce((acc, key)=>{
|
|
143
168
|
const fn = contents[key];
|
|
@@ -160,8 +185,33 @@ function evalMetroAndWrapFunctions(projectRoot, script) {
|
|
|
160
185
|
return acc;
|
|
161
186
|
}, {});
|
|
162
187
|
}
|
|
163
|
-
function evalMetro(src) {
|
|
164
|
-
|
|
188
|
+
function evalMetro(projectRoot, src, filename) {
|
|
189
|
+
const originalConsole = {
|
|
190
|
+
log: console.log,
|
|
191
|
+
warn: console.warn,
|
|
192
|
+
error: console.error
|
|
193
|
+
};
|
|
194
|
+
try {
|
|
195
|
+
return (0, _profile).profile(_requireFromString.default, "eval-metro-bundle")(src, filename);
|
|
196
|
+
} catch (error) {
|
|
197
|
+
// Format any errors that were thrown in the global scope of the evaluation.
|
|
198
|
+
if (error instanceof Error) {
|
|
199
|
+
(0, _metroErrorInterface).logMetroErrorAsync({
|
|
200
|
+
projectRoot,
|
|
201
|
+
error
|
|
202
|
+
}).catch((internalError)=>{
|
|
203
|
+
debug("Failed to log metro error:", internalError);
|
|
204
|
+
throw error;
|
|
205
|
+
});
|
|
206
|
+
} else {
|
|
207
|
+
throw error;
|
|
208
|
+
}
|
|
209
|
+
} finally{
|
|
210
|
+
// Restore the original console in case it was modified.
|
|
211
|
+
console.log = originalConsole.log;
|
|
212
|
+
console.warn = originalConsole.warn;
|
|
213
|
+
console.error = originalConsole.error;
|
|
214
|
+
}
|
|
165
215
|
}
|
|
166
216
|
|
|
167
217
|
//# sourceMappingURL=getStaticRenderFunctions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/start/server/getStaticRenderFunctions.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport fs from 'fs';\nimport fetch from 'node-fetch';\nimport path from 'path';\nimport requireString from 'require-from-string';\nimport resolveFrom from 'resolve-from';\n\nimport { logMetroError } from './metro/metroErrorInterface';\nimport { getMetroServerRoot } from './middleware/ManifestMiddleware';\nimport { createBundleUrlPath } from './middleware/metroOptions';\nimport { stripAnsi } from '../../utils/ansi';\nimport { delayAsync } from '../../utils/delay';\nimport { SilentError } from '../../utils/errors';\nimport { memoize } from '../../utils/fn';\nimport { profile } from '../../utils/profile';\n\nconst debug = require('debug')('expo:start:server:node-renderer') as typeof console.log;\n\nfunction wrapBundle(str: string) {\n // Skip the metro runtime so debugging is a bit easier.\n // Replace the __r() call with an export statement.\n // Use gm to apply to the last require line. This is needed when the bundle has side-effects.\n return str.replace(/^(__r\\(.*\\);)$/gm, 'module.exports = $1');\n}\n\n// TODO(EvanBacon): Group all the code together and version.\nconst getRenderModuleId = (projectRoot: string): string => {\n const moduleId = resolveFrom.silent(projectRoot, 'expo-router/node/render.js');\n if (!moduleId) {\n throw new Error(\n `A version of expo-router with Node.js support is not installed in the project.`\n );\n }\n\n return moduleId;\n};\n\ntype StaticRenderOptions = {\n // Ensure the style format is `css-xxxx` (prod) instead of `css-view-xxxx` (dev)\n dev?: boolean;\n minify?: boolean;\n platform?: string;\n environment?: 'node';\n engine?: 'hermes';\n baseUrl: string;\n routerRoot: string;\n};\n\nconst moveStaticRenderFunction = memoize(async (projectRoot: string, requiredModuleId: string) => {\n // Copy the file into the project to ensure it works in monorepos.\n // This means the file cannot have any relative imports.\n const tempDir = path.join(projectRoot, '.expo/static');\n await fs.promises.mkdir(tempDir, { recursive: true });\n const moduleId = path.join(tempDir, 'render.js');\n await fs.promises.writeFile(moduleId, await fs.promises.readFile(requiredModuleId, 'utf8'));\n // Sleep to give watchman time to register the file.\n await delayAsync(50);\n return moduleId;\n});\n\n/** @returns the js file contents required to generate the static generation function. */\nasync function getStaticRenderFunctionsContentAsync(\n projectRoot: string,\n devServerUrl: string,\n { dev = false, minify = false, environment, baseUrl, routerRoot }: StaticRenderOptions\n): Promise<string> {\n const root = getMetroServerRoot(projectRoot);\n const requiredModuleId = getRenderModuleId(root);\n let moduleId = requiredModuleId;\n\n // Cannot be accessed using Metro's server API, we need to move the file\n // into the project root and try again.\n if (path.relative(root, moduleId).startsWith('..')) {\n moduleId = await moveStaticRenderFunction(projectRoot, requiredModuleId);\n }\n\n return requireFileContentsWithMetro(root, devServerUrl, moduleId, {\n dev,\n minify,\n environment,\n baseUrl,\n routerRoot,\n });\n}\n\nasync function ensureFileInRootDirectory(projectRoot: string, otherFile: string) {\n // Cannot be accessed using Metro's server API, we need to move the file\n // into the project root and try again.\n if (!path.relative(projectRoot, otherFile).startsWith('..' + path.sep)) {\n return otherFile;\n }\n\n // Copy the file into the project to ensure it works in monorepos.\n // This means the file cannot have any relative imports.\n const tempDir = path.join(projectRoot, '.expo/static-tmp');\n await fs.promises.mkdir(tempDir, { recursive: true });\n const moduleId = path.join(tempDir, path.basename(otherFile));\n await fs.promises.writeFile(moduleId, await fs.promises.readFile(otherFile, 'utf8'));\n // Sleep to give watchman time to register the file.\n await delayAsync(50);\n return moduleId;\n}\n\nexport async function createMetroEndpointAsync(\n projectRoot: string,\n devServerUrl: string,\n absoluteFilePath: string,\n {\n dev = false,\n platform = 'web',\n minify = false,\n environment,\n engine = 'hermes',\n baseUrl,\n routerRoot,\n }: StaticRenderOptions\n): Promise<string> {\n const root = getMetroServerRoot(projectRoot);\n const safeOtherFile = await ensureFileInRootDirectory(projectRoot, absoluteFilePath);\n const serverPath = path.relative(root, safeOtherFile).replace(/\\.[jt]sx?$/, '');\n\n const urlFragment = createBundleUrlPath({\n platform,\n mode: dev ? 'development' : 'production',\n mainModuleName: serverPath,\n engine,\n environment,\n lazy: false,\n minify,\n baseUrl,\n isExporting: true,\n asyncRoutes: false,\n routerRoot,\n });\n\n const url = new URL(urlFragment.replace(/^\\//, ''), devServerUrl).toString();\n debug('fetching from Metro:', root, serverPath, url);\n return url;\n}\n\nclass MetroNodeError extends Error {\n constructor(\n message: string,\n public rawObject: any\n ) {\n super(message);\n }\n}\n\nexport async function requireFileContentsWithMetro(\n projectRoot: string,\n devServerUrl: string,\n absoluteFilePath: string,\n props: StaticRenderOptions\n): Promise<string> {\n const url = await createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFilePath, props);\n\n const res = await fetch(url);\n\n // TODO: Improve error handling\n if (res.status === 500) {\n const text = await res.text();\n if (text.startsWith('{\"originModulePath\"') || text.startsWith('{\"type\":\"TransformError\"')) {\n const errorObject = JSON.parse(text);\n\n throw new MetroNodeError(stripAnsi(errorObject.message) ?? errorObject.message, errorObject);\n }\n throw new Error(`[${res.status}]: ${res.statusText}\\n${text}`);\n }\n\n if (!res.ok) {\n throw new Error(`Error fetching bundle for static rendering: ${res.status} ${res.statusText}`);\n }\n\n const content = await res.text();\n\n return wrapBundle(content);\n}\n\nexport async function getStaticRenderFunctions(\n projectRoot: string,\n devServerUrl: string,\n options: StaticRenderOptions\n): Promise<Record<string, (...args: any[]) => Promise<any>>> {\n const scriptContents = await getStaticRenderFunctionsContentAsync(\n projectRoot,\n devServerUrl,\n options\n );\n\n return evalMetroAndWrapFunctions(projectRoot, scriptContents);\n}\n\nfunction evalMetroAndWrapFunctions<T = Record<string, (...args: any[]) => Promise<any>>>(\n projectRoot: string,\n script: string\n): Promise<T> {\n const contents = evalMetro(script);\n\n // wrap each function with a try/catch that uses Metro's error formatter\n return Object.keys(contents).reduce((acc, key) => {\n const fn = contents[key];\n if (typeof fn !== 'function') {\n return { ...acc, [key]: fn };\n }\n\n acc[key] = async function (...props: any[]) {\n try {\n return await fn.apply(this, props);\n } catch (error: any) {\n await logMetroError(projectRoot, { error });\n throw new SilentError(error);\n }\n };\n return acc;\n }, {} as any);\n}\n\nfunction evalMetro(src: string) {\n return profile(requireString, 'eval-metro-bundle')(src);\n}\n"],"names":["createMetroEndpointAsync","requireFileContentsWithMetro","getStaticRenderFunctions","debug","require","wrapBundle","str","replace","getRenderModuleId","projectRoot","moduleId","resolveFrom","silent","Error","moveStaticRenderFunction","memoize","requiredModuleId","tempDir","path","join","fs","promises","mkdir","recursive","writeFile","readFile","delayAsync","getStaticRenderFunctionsContentAsync","devServerUrl","dev","minify","environment","baseUrl","routerRoot","root","getMetroServerRoot","relative","startsWith","ensureFileInRootDirectory","otherFile","sep","basename","absoluteFilePath","platform","engine","safeOtherFile","serverPath","urlFragment","createBundleUrlPath","mode","mainModuleName","lazy","isExporting","asyncRoutes","url","URL","toString","MetroNodeError","constructor","message","rawObject","props","res","fetch","status","text","errorObject","JSON","parse","stripAnsi","statusText","ok","content","options","scriptContents","evalMetroAndWrapFunctions","script","contents","evalMetro","Object","keys","reduce","acc","key","fn","apply","error","logMetroError","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Aa,QAAA,EAAE,mBAAmB,CAAC,CAACF,GAAG,CAAC,CAAC;CACzD"}
|
|
1
|
+
{"version":3,"sources":["../../../../src/start/server/getStaticRenderFunctions.ts"],"sourcesContent":["/**\n * Copyright © 2022 650 Industries.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport fs from 'fs';\nimport fetch from 'node-fetch';\nimport path from 'path';\nimport requireString from 'require-from-string';\nimport resolveFrom from 'resolve-from';\n\nimport { logMetroError, logMetroErrorAsync } from './metro/metroErrorInterface';\nimport { getMetroServerRoot } from './middleware/ManifestMiddleware';\nimport { createBundleUrlPath } from './middleware/metroOptions';\nimport { stripAnsi } from '../../utils/ansi';\nimport { delayAsync } from '../../utils/delay';\nimport { SilentError } from '../../utils/errors';\nimport { memoize } from '../../utils/fn';\nimport { profile } from '../../utils/profile';\n\ntype StaticRenderOptions = {\n // Ensure the style format is `css-xxxx` (prod) instead of `css-view-xxxx` (dev)\n dev?: boolean;\n minify?: boolean;\n platform?: string;\n environment?: 'node';\n engine?: 'hermes';\n baseUrl: string;\n routerRoot: string;\n};\n\nclass MetroNodeError extends Error {\n constructor(\n message: string,\n public rawObject: any\n ) {\n super(message);\n }\n}\n\nconst debug = require('debug')('expo:start:server:node-renderer') as typeof console.log;\n\nconst cachedSourceMaps: Map<string, { url: string; map: string }> = new Map();\n\n// Support unhandled rejections\nrequire('source-map-support').install({\n retrieveSourceMap(source: string) {\n if (cachedSourceMaps.has(source)) {\n return cachedSourceMaps.get(source);\n }\n return null;\n },\n});\n\nfunction wrapBundle(str: string) {\n // Skip the metro runtime so debugging is a bit easier.\n // Replace the __r() call with an export statement.\n // Use gm to apply to the last require line. This is needed when the bundle has side-effects.\n return str.replace(/^(__r\\(.*\\);)$/gm, 'module.exports = $1');\n}\n\n// TODO(EvanBacon): Group all the code together and version.\nconst getRenderModuleId = (projectRoot: string): string => {\n const moduleId = resolveFrom.silent(projectRoot, 'expo-router/node/render.js');\n if (!moduleId) {\n throw new Error(\n `A version of expo-router with Node.js support is not installed in the project.`\n );\n }\n\n return moduleId;\n};\n\nconst moveStaticRenderFunction = memoize(async (projectRoot: string, requiredModuleId: string) => {\n // Copy the file into the project to ensure it works in monorepos.\n // This means the file cannot have any relative imports.\n const tempDir = path.join(projectRoot, '.expo/static');\n await fs.promises.mkdir(tempDir, { recursive: true });\n const moduleId = path.join(tempDir, 'render.js');\n await fs.promises.writeFile(moduleId, await fs.promises.readFile(requiredModuleId, 'utf8'));\n // Sleep to give watchman time to register the file.\n await delayAsync(50);\n return moduleId;\n});\n\n/** @returns the js file contents required to generate the static generation function. */\nasync function getStaticRenderFunctionsContentAsync(\n projectRoot: string,\n devServerUrl: string,\n { dev = false, minify = false, environment, baseUrl, routerRoot }: StaticRenderOptions\n): Promise<{ src: string; filename: string }> {\n const root = getMetroServerRoot(projectRoot);\n const requiredModuleId = getRenderModuleId(root);\n let moduleId = requiredModuleId;\n\n // Cannot be accessed using Metro's server API, we need to move the file\n // into the project root and try again.\n if (path.relative(root, moduleId).startsWith('..')) {\n moduleId = await moveStaticRenderFunction(projectRoot, requiredModuleId);\n }\n\n return requireFileContentsWithMetro(root, devServerUrl, moduleId, {\n dev,\n minify,\n environment,\n baseUrl,\n routerRoot,\n });\n}\n\nasync function ensureFileInRootDirectory(projectRoot: string, otherFile: string) {\n // Cannot be accessed using Metro's server API, we need to move the file\n // into the project root and try again.\n if (!path.relative(projectRoot, otherFile).startsWith('..' + path.sep)) {\n return otherFile;\n }\n\n // Copy the file into the project to ensure it works in monorepos.\n // This means the file cannot have any relative imports.\n const tempDir = path.join(projectRoot, '.expo/static-tmp');\n await fs.promises.mkdir(tempDir, { recursive: true });\n const moduleId = path.join(tempDir, path.basename(otherFile));\n await fs.promises.writeFile(moduleId, await fs.promises.readFile(otherFile, 'utf8'));\n // Sleep to give watchman time to register the file.\n await delayAsync(50);\n return moduleId;\n}\n\nexport async function createMetroEndpointAsync(\n projectRoot: string,\n devServerUrl: string,\n absoluteFilePath: string,\n {\n dev = false,\n platform = 'web',\n minify = false,\n environment,\n engine = 'hermes',\n baseUrl,\n routerRoot,\n }: StaticRenderOptions\n): Promise<string> {\n const root = getMetroServerRoot(projectRoot);\n const safeOtherFile = await ensureFileInRootDirectory(projectRoot, absoluteFilePath);\n const serverPath = path.relative(root, safeOtherFile).replace(/\\.[jt]sx?$/, '');\n\n const urlFragment = createBundleUrlPath({\n platform,\n mode: dev ? 'development' : 'production',\n mainModuleName: serverPath,\n engine,\n environment,\n lazy: false,\n minify,\n baseUrl,\n isExporting: true,\n asyncRoutes: false,\n routerRoot,\n inlineSourceMap: false,\n });\n\n let url: string;\n if (devServerUrl) {\n url = new URL(urlFragment.replace(/^\\//, ''), devServerUrl).toString();\n } else {\n url = '/' + urlFragment.replace(/^\\/+/, '');\n }\n debug('fetching from Metro:', root, serverPath, url);\n return url;\n}\n\nexport async function requireFileContentsWithMetro(\n projectRoot: string,\n devServerUrl: string,\n absoluteFilePath: string,\n props: StaticRenderOptions\n): Promise<{ src: string; filename: string }> {\n const url = await createMetroEndpointAsync(projectRoot, devServerUrl, absoluteFilePath, props);\n\n const res = await fetch(url);\n\n // TODO: Improve error handling\n if (res.status === 500) {\n const text = await res.text();\n if (text.startsWith('{\"originModulePath\"') || text.startsWith('{\"type\":\"TransformError\"')) {\n const errorObject = JSON.parse(text);\n\n throw new MetroNodeError(stripAnsi(errorObject.message) ?? errorObject.message, errorObject);\n }\n throw new Error(`[${res.status}]: ${res.statusText}\\n${text}`);\n }\n\n if (!res.ok) {\n throw new Error(`Error fetching bundle for static rendering: ${res.status} ${res.statusText}`);\n }\n\n const content = await res.text();\n\n const map = await fetch(url.replace('.bundle?', '.map?')).then((r) => r.json());\n cachedSourceMaps.set(url, { url: projectRoot, map });\n\n return { src: wrapBundle(content), filename: url };\n}\n\nexport async function getStaticRenderFunctions(\n projectRoot: string,\n devServerUrl: string,\n options: StaticRenderOptions\n): Promise<Record<string, (...args: any[]) => Promise<any>>> {\n const { src: scriptContents, filename } = await getStaticRenderFunctionsContentAsync(\n projectRoot,\n devServerUrl,\n options\n );\n\n return evalMetroAndWrapFunctions(projectRoot, scriptContents, filename);\n}\n\nfunction evalMetroAndWrapFunctions<T = Record<string, (...args: any[]) => Promise<any>>>(\n projectRoot: string,\n script: string,\n filename: string\n): Promise<T> {\n const contents = evalMetro(projectRoot, script, filename);\n\n // wrap each function with a try/catch that uses Metro's error formatter\n return Object.keys(contents).reduce((acc, key) => {\n const fn = contents[key];\n if (typeof fn !== 'function') {\n return { ...acc, [key]: fn };\n }\n\n acc[key] = async function (...props: any[]) {\n try {\n return await fn.apply(this, props);\n } catch (error: any) {\n await logMetroError(projectRoot, { error });\n throw new SilentError(error);\n }\n };\n return acc;\n }, {} as any);\n}\n\nfunction evalMetro(projectRoot: string, src: string, filename: string) {\n const originalConsole = {\n log: console.log,\n warn: console.warn,\n error: console.error,\n };\n try {\n return profile(requireString, 'eval-metro-bundle')(src, filename);\n } catch (error: any) {\n // Format any errors that were thrown in the global scope of the evaluation.\n if (error instanceof Error) {\n logMetroErrorAsync({ projectRoot, error }).catch((internalError) => {\n debug('Failed to log metro error:', internalError);\n throw error;\n });\n } else {\n throw error;\n }\n } finally {\n // Restore the original console in case it was modified.\n console.log = originalConsole.log;\n console.warn = originalConsole.warn;\n console.error = originalConsole.error;\n }\n}\n"],"names":["createMetroEndpointAsync","requireFileContentsWithMetro","getStaticRenderFunctions","MetroNodeError","Error","constructor","message","rawObject","debug","require","cachedSourceMaps","Map","install","retrieveSourceMap","source","has","get","wrapBundle","str","replace","getRenderModuleId","projectRoot","moduleId","resolveFrom","silent","moveStaticRenderFunction","memoize","requiredModuleId","tempDir","path","join","fs","promises","mkdir","recursive","writeFile","readFile","delayAsync","getStaticRenderFunctionsContentAsync","devServerUrl","dev","minify","environment","baseUrl","routerRoot","root","getMetroServerRoot","relative","startsWith","ensureFileInRootDirectory","otherFile","sep","basename","absoluteFilePath","platform","engine","safeOtherFile","serverPath","urlFragment","createBundleUrlPath","mode","mainModuleName","lazy","isExporting","asyncRoutes","inlineSourceMap","url","URL","toString","props","res","fetch","status","text","errorObject","JSON","parse","stripAnsi","statusText","ok","content","map","then","r","json","set","src","filename","options","scriptContents","evalMetroAndWrapFunctions","script","contents","evalMetro","Object","keys","reduce","acc","key","fn","apply","error","logMetroError","SilentError","originalConsole","log","console","warn","profile","requireString","logMetroErrorAsync","catch","internalError"],"mappings":"AAMA;;;;QA2HsBA,wBAAwB,GAAxBA,wBAAwB;QA2CxBC,4BAA4B,GAA5BA,4BAA4B;QAiC5BC,wBAAwB,GAAxBA,wBAAwB;AAvM/B,IAAA,GAAI,kCAAJ,IAAI,EAAA;AACD,IAAA,UAAY,kCAAZ,YAAY,EAAA;AACb,IAAA,KAAM,kCAAN,MAAM,EAAA;AACG,IAAA,kBAAqB,kCAArB,qBAAqB,EAAA;AACvB,IAAA,YAAc,kCAAd,cAAc,EAAA;AAEY,IAAA,oBAA6B,WAA7B,6BAA6B,CAAA;AAC5C,IAAA,mBAAiC,WAAjC,iCAAiC,CAAA;AAChC,IAAA,aAA2B,WAA3B,2BAA2B,CAAA;AACrC,IAAA,KAAkB,WAAlB,kBAAkB,CAAA;AACjB,IAAA,MAAmB,WAAnB,mBAAmB,CAAA;AAClB,IAAA,OAAoB,WAApB,oBAAoB,CAAA;AACxB,IAAA,GAAgB,WAAhB,gBAAgB,CAAA;AAChB,IAAA,QAAqB,WAArB,qBAAqB,CAAA;;;;;;AAa7C,MAAMC,cAAc,SAASC,KAAK;IAChCC,YACEC,OAAe,EACRC,SAAc,CACrB;QACA,KAAK,CAACD,OAAO,CAAC,CAAC;aAFRC,SAAc,GAAdA,SAAc;KAGtB;CACF;AAED,MAAMC,KAAK,GAAGC,OAAO,CAAC,OAAO,CAAC,CAAC,iCAAiC,CAAC,AAAsB,AAAC;AAExF,MAAMC,gBAAgB,GAA8C,IAAIC,GAAG,EAAE,AAAC;AAE9E,+BAA+B;AAC/BF,OAAO,CAAC,oBAAoB,CAA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AAG,EAAEC,OAAO,CAACD,GAAG;QAChBE,IAAI,EAAED,OAAO,CAACC,IAAI;QAClBN,KAAK,EAAEK,OAAO,CAACL,KAAK;KACrB,AAAC;IACF,IAAI;QACF,OAAOO,CAAAA,GAAAA,QAAO,AAAoC,CAAA,QAApC,CAACC,kBAAa,QAAA,EAAE,mBAAmB,CAAC,CAACvB,GAAG,EAAEC,QAAQ,CAAC,CAAC;KACnE,CAAC,OAAOc,KAAK,EAAO;QACnB,4EAA4E;QAC5E,IAAIA,KAAK,YAAYjG,KAAK,EAAE;YAC1B0G,CAAAA,GAAAA,oBAAkB,AAAwB,CAAA,mBAAxB,CAAC;gBAAEzF,WAAW;gBAAEgF,KAAK;aAAE,CAAC,CAACU,KAAK,CAAC,CAACC,aAAa,GAAK;gBAClExG,KAAK,CAAC,4BAA4B,EAAEwG,aAAa,CAAC,CAAC;gBACnD,MAAMX,KAAK,CAAC;aACb,CAAC,CAAC;SACJ,MAAM;YACL,MAAMA,KAAK,CAAC;SACb;KACF,QAAS;QACR,wDAAwD;QACxDK,OAAO,CAACD,GAAG,GAAGD,eAAe,CAACC,GAAG,CAAC;QAClCC,OAAO,CAACC,IAAI,GAAGH,eAAe,CAACG,IAAI,CAAC;QACpCD,OAAO,CAACL,KAAK,GAAGG,eAAe,CAACH,KAAK,CAAC;KACvC;CACF"}
|
|
@@ -104,7 +104,7 @@ class MetroBundlerDevServer extends _bundlerDevServer.BundlerDevServer {
|
|
|
104
104
|
const artifactFilename = _path.default.join(outputDir, _path.default.relative(appDir, filepath.replace(/\.[tj]sx?$/, ".js")));
|
|
105
105
|
if (contents) {
|
|
106
106
|
files.set(artifactFilename, {
|
|
107
|
-
contents,
|
|
107
|
+
contents: contents.src,
|
|
108
108
|
targetDomain: "server"
|
|
109
109
|
});
|
|
110
110
|
}
|