@expo/config-plugins 9.0.9 → 9.0.10

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.
@@ -70,6 +70,7 @@ function resolvePluginForModule(projectRoot, pluginReference) {
70
70
  const pluginScriptFile = _resolveFrom().default.silent(projectRoot, pluginReference);
71
71
  if (pluginScriptFile) {
72
72
  return {
73
+ // NOTE(cedric): `path.sep` is required here, we are resolving the absolute path, not the plugin reference
73
74
  isPluginFile: pluginScriptFile.endsWith(path().sep + pluginFileName),
74
75
  filePath: pluginScriptFile
75
76
  };
@@ -104,7 +105,7 @@ function moduleNameIsDirectFileReference(name) {
104
105
  if (pathIsFilePath(name)) {
105
106
  return true;
106
107
  }
107
- const slashCount = name.split(path().sep)?.length;
108
+ const slashCount = name.split('/')?.length;
108
109
  // Orgs (like @expo/config ) should have more than one slash to be a direct file.
109
110
  if (name.startsWith('@')) {
110
111
  return slashCount > 2;
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-resolver.js","names":["_assert","data","_interopRequireDefault","require","path","_interopRequireWildcard","_resolveFrom","_errors","_modules","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","pluginFileName","exports","resolvePluginForModule","projectRoot","pluginReference","moduleNameIsDirectFileReference","pluginScriptFile","resolveFrom","silent","isPluginFile","endsWith","sep","filePath","moduleNameIsPackageReference","pluginPackageFile","fileExists","packageMainEntry","PluginError","pathIsFilePath","name","match","slashCount","split","length","startsWith","normalizeStaticPlugin","plugin","Array","isArray","assert","undefined","assertInternalProjectRoot","resolveConfigPluginFunction","resolveConfigPluginFunctionWithInfo","pluginFile","result","requirePluginFile","error","SyntaxError","learnMoreLink","pluginError","message","stack","resolveConfigPluginExport"],"sources":["../../src/utils/plugin-resolver.ts"],"sourcesContent":["import assert from 'assert';\nimport * as path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { PluginError } from './errors';\nimport { ConfigPlugin, StaticPlugin } from '../Plugin.types';\nimport { fileExists } from './modules';\n// Default plugin entry file name.\nexport const pluginFileName = 'app.plugin.js';\n\n/**\n * Resolve the config plugin from a node module or package.\n * If the module or package does not include a config plugin, this function throws a `PluginError`.\n * The resolution is done in following order:\n * 1. Is the reference a relative file path or an import specifier with file path? e.g. `./file.js`, `pkg/file.js` or `@org/pkg/file.js`?\n * - Resolve the config plugin as-is\n * 2. If the reference a module? e.g. `expo-font`\n * - Resolve the root `app.plugin.js` file within the module, e.g. `expo-font/app.plugin.js`\n * 3. Does the module have a valid config plugin in the `main` field?\n * - Resolve the `main` entry point as config plugin\n */\nexport function resolvePluginForModule(\n projectRoot: string,\n pluginReference: string\n): { filePath: string; isPluginFile: boolean } {\n if (moduleNameIsDirectFileReference(pluginReference)) {\n // Only resolve `./file.js`, `package/file.js`, `@org/package/file.js`\n const pluginScriptFile = resolveFrom.silent(projectRoot, pluginReference);\n if (pluginScriptFile) {\n return {\n isPluginFile: pluginScriptFile.endsWith(path.sep + pluginFileName),\n filePath: pluginScriptFile,\n };\n }\n } else if (moduleNameIsPackageReference(pluginReference)) {\n // Only resolve `package -> package/app.plugin.js`, `@org/package -> @org/package/app.plugin.js`\n const pluginPackageFile = resolveFrom.silent(\n projectRoot,\n `${pluginReference}/${pluginFileName}`\n );\n if (pluginPackageFile && fileExists(pluginPackageFile)) {\n return { isPluginFile: true, filePath: pluginPackageFile };\n }\n // Try to resole the `main` entry as config plugin\n const packageMainEntry = resolveFrom.silent(projectRoot, pluginReference);\n if (packageMainEntry) {\n return { isPluginFile: false, filePath: packageMainEntry };\n }\n }\n\n throw new PluginError(\n `Failed to resolve plugin for module \"${pluginReference}\" relative to \"${projectRoot}\"`,\n 'PLUGIN_NOT_FOUND'\n );\n}\n\n// TODO: Test windows\nfunction pathIsFilePath(name: string): boolean {\n // Matches lines starting with: . / ~/\n return !!name.match(/^(\\.|~\\/|\\/)/g);\n}\n\nexport function moduleNameIsDirectFileReference(name: string): boolean {\n if (pathIsFilePath(name)) {\n return true;\n }\n\n const slashCount = name.split(path.sep)?.length;\n // Orgs (like @expo/config ) should have more than one slash to be a direct file.\n if (name.startsWith('@')) {\n return slashCount > 2;\n }\n\n // Regular packages should be considered direct reference if they have more than one slash.\n return slashCount > 1;\n}\n\nexport function moduleNameIsPackageReference(name: string): boolean {\n const slashCount = name.split('/')?.length;\n return name.startsWith('@') ? slashCount === 2 : slashCount === 1;\n}\n\nexport function normalizeStaticPlugin(plugin: StaticPlugin | ConfigPlugin | string): StaticPlugin {\n if (Array.isArray(plugin)) {\n assert(\n plugin.length > 0 && plugin.length < 3,\n `Wrong number of arguments provided for static config plugin, expected either 1 or 2, got ${plugin.length}`\n );\n return plugin;\n }\n return [plugin, undefined];\n}\n\nexport function assertInternalProjectRoot(projectRoot?: string): asserts projectRoot {\n assert(\n projectRoot,\n `Unexpected: Config \\`_internal.projectRoot\\` isn't defined by expo-cli, this is a bug.`\n );\n}\n\n// Resolve the module function and assert type\nexport function resolveConfigPluginFunction(projectRoot: string, pluginReference: string) {\n const { plugin } = resolveConfigPluginFunctionWithInfo(projectRoot, pluginReference);\n return plugin;\n}\n\n// Resolve the module function and assert type\nexport function resolveConfigPluginFunctionWithInfo(projectRoot: string, pluginReference: string) {\n const { filePath: pluginFile, isPluginFile } = resolvePluginForModule(\n projectRoot,\n pluginReference\n );\n let result: any;\n try {\n result = requirePluginFile(pluginFile);\n } catch (error) {\n if (error instanceof SyntaxError) {\n const learnMoreLink = `Learn more: https://docs.expo.dev/guides/config-plugins/#creating-a-plugin`;\n // If the plugin reference is a node module, and that node module has a syntax error, then it probably doesn't have an official config plugin.\n if (!isPluginFile && !moduleNameIsDirectFileReference(pluginReference)) {\n const pluginError = new PluginError(\n `Package \"${pluginReference}\" does not contain a valid config plugin.\\n${learnMoreLink}\\n\\n${error.message}`,\n 'INVALID_PLUGIN_IMPORT'\n );\n pluginError.stack = error.stack;\n throw pluginError;\n }\n }\n throw error;\n }\n\n const plugin = resolveConfigPluginExport({\n plugin: result,\n pluginFile,\n pluginReference,\n isPluginFile,\n });\n return { plugin, pluginFile, pluginReference, isPluginFile };\n}\n\n/**\n * - Resolve the exported contents of an Expo config (be it default or module.exports)\n * - Assert no promise exports\n * - Return config type\n * - Serialize config\n *\n * @param props.plugin plugin results\n * @param props.pluginFile plugin file path\n * @param props.pluginReference the string used to reference the plugin\n * @param props.isPluginFile is file path from the app.plugin.js module root\n */\nexport function resolveConfigPluginExport({\n plugin,\n pluginFile,\n pluginReference,\n isPluginFile,\n}: {\n plugin: any;\n pluginFile: string;\n pluginReference: string;\n isPluginFile: boolean;\n}): ConfigPlugin<unknown> {\n if (plugin.default != null) {\n plugin = plugin.default;\n }\n if (typeof plugin !== 'function') {\n const learnMoreLink = `Learn more: https://docs.expo.dev/guides/config-plugins/#creating-a-plugin`;\n // If the plugin reference is a node module, and that node module does not export a function then it probably doesn't have a config plugin.\n if (!isPluginFile && !moduleNameIsDirectFileReference(pluginReference)) {\n throw new PluginError(\n `Package \"${pluginReference}\" does not contain a valid config plugin. Module must export a function from file: ${pluginFile}\\n${learnMoreLink}`,\n 'INVALID_PLUGIN_TYPE'\n );\n }\n throw new PluginError(\n `Plugin \"${pluginReference}\" must export a function from file: ${pluginFile}. ${learnMoreLink}`,\n 'INVALID_PLUGIN_TYPE'\n );\n }\n\n return plugin;\n}\n\nfunction requirePluginFile(filePath: string): any {\n try {\n return require(filePath);\n } catch (error) {\n // TODO: Improve error messages\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAG,KAAA;EAAA,MAAAH,IAAA,GAAAI,uBAAA,CAAAF,OAAA;EAAAC,IAAA,YAAAA,CAAA;IAAA,OAAAH,IAAA;EAAA;EA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EACNQ,UAAU;EACV9B,eAAe;EACfK;AAMF,CAAC,EAAyB;EACxB,IAAIiB,MAAM,CAACxC,OAAO,IAAI,IAAI,EAAE;IAC1BwC,MAAM,GAAGA,MAAM,CAACxC,OAAO;EACzB;EACA,IAAI,OAAOwC,MAAM,KAAK,UAAU,EAAE;IAChC,MAAMa,aAAa,GAAG,4EAA4E;IAClG;IACA,IAAI,CAAC9B,YAAY,IAAI,CAACJ,+BAA+B,CAACD,eAAe,CAAC,EAAE;MACtE,MAAM,KAAIa,qBAAW,EACnB,YAAYb,eAAe,sFAAsF8B,UAAU,KAAKK,aAAa,EAAE,EAC/I,qBACF,CAAC;IACH;IACA,MAAM,KAAItB,qBAAW,EACnB,WAAWb,eAAe,uCAAuC8B,UAAU,KAAKK,aAAa,EAAE,EAC/F,qBACF,CAAC;EACH;EAEA,OAAOb,MAAM;AACf;AAEA,SAASU,iBAAiBA,CAACxB,QAAgB,EAAO;EAChD,IAAI;IACF,OAAOtC,OAAO,CAACsC,QAAQ,CAAC;EAC1B,CAAC,CAAC,OAAOyB,KAAK,EAAE;IACd;IACA,MAAMA,KAAK;EACb;AACF","ignoreList":[]}
1
+ {"version":3,"file":"plugin-resolver.js","names":["_assert","data","_interopRequireDefault","require","path","_interopRequireWildcard","_resolveFrom","_errors","_modules","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","pluginFileName","exports","resolvePluginForModule","projectRoot","pluginReference","moduleNameIsDirectFileReference","pluginScriptFile","resolveFrom","silent","isPluginFile","endsWith","sep","filePath","moduleNameIsPackageReference","pluginPackageFile","fileExists","packageMainEntry","PluginError","pathIsFilePath","name","match","slashCount","split","length","startsWith","normalizeStaticPlugin","plugin","Array","isArray","assert","undefined","assertInternalProjectRoot","resolveConfigPluginFunction","resolveConfigPluginFunctionWithInfo","pluginFile","result","requirePluginFile","error","SyntaxError","learnMoreLink","pluginError","message","stack","resolveConfigPluginExport"],"sources":["../../src/utils/plugin-resolver.ts"],"sourcesContent":["import assert from 'assert';\nimport * as path from 'path';\nimport resolveFrom from 'resolve-from';\n\nimport { PluginError } from './errors';\nimport { ConfigPlugin, StaticPlugin } from '../Plugin.types';\nimport { fileExists } from './modules';\n// Default plugin entry file name.\nexport const pluginFileName = 'app.plugin.js';\n\n/**\n * Resolve the config plugin from a node module or package.\n * If the module or package does not include a config plugin, this function throws a `PluginError`.\n * The resolution is done in following order:\n * 1. Is the reference a relative file path or an import specifier with file path? e.g. `./file.js`, `pkg/file.js` or `@org/pkg/file.js`?\n * - Resolve the config plugin as-is\n * 2. If the reference a module? e.g. `expo-font`\n * - Resolve the root `app.plugin.js` file within the module, e.g. `expo-font/app.plugin.js`\n * 3. Does the module have a valid config plugin in the `main` field?\n * - Resolve the `main` entry point as config plugin\n */\nexport function resolvePluginForModule(\n projectRoot: string,\n pluginReference: string\n): { filePath: string; isPluginFile: boolean } {\n if (moduleNameIsDirectFileReference(pluginReference)) {\n // Only resolve `./file.js`, `package/file.js`, `@org/package/file.js`\n const pluginScriptFile = resolveFrom.silent(projectRoot, pluginReference);\n if (pluginScriptFile) {\n return {\n // NOTE(cedric): `path.sep` is required here, we are resolving the absolute path, not the plugin reference\n isPluginFile: pluginScriptFile.endsWith(path.sep + pluginFileName),\n filePath: pluginScriptFile,\n };\n }\n } else if (moduleNameIsPackageReference(pluginReference)) {\n // Only resolve `package -> package/app.plugin.js`, `@org/package -> @org/package/app.plugin.js`\n const pluginPackageFile = resolveFrom.silent(\n projectRoot,\n `${pluginReference}/${pluginFileName}`\n );\n if (pluginPackageFile && fileExists(pluginPackageFile)) {\n return { isPluginFile: true, filePath: pluginPackageFile };\n }\n // Try to resole the `main` entry as config plugin\n const packageMainEntry = resolveFrom.silent(projectRoot, pluginReference);\n if (packageMainEntry) {\n return { isPluginFile: false, filePath: packageMainEntry };\n }\n }\n\n throw new PluginError(\n `Failed to resolve plugin for module \"${pluginReference}\" relative to \"${projectRoot}\"`,\n 'PLUGIN_NOT_FOUND'\n );\n}\n\n// TODO: Test windows\nfunction pathIsFilePath(name: string): boolean {\n // Matches lines starting with: . / ~/\n return !!name.match(/^(\\.|~\\/|\\/)/g);\n}\n\nexport function moduleNameIsDirectFileReference(name: string): boolean {\n if (pathIsFilePath(name)) {\n return true;\n }\n\n const slashCount = name.split('/')?.length;\n // Orgs (like @expo/config ) should have more than one slash to be a direct file.\n if (name.startsWith('@')) {\n return slashCount > 2;\n }\n\n // Regular packages should be considered direct reference if they have more than one slash.\n return slashCount > 1;\n}\n\nexport function moduleNameIsPackageReference(name: string): boolean {\n const slashCount = name.split('/')?.length;\n return name.startsWith('@') ? slashCount === 2 : slashCount === 1;\n}\n\nexport function normalizeStaticPlugin(plugin: StaticPlugin | ConfigPlugin | string): StaticPlugin {\n if (Array.isArray(plugin)) {\n assert(\n plugin.length > 0 && plugin.length < 3,\n `Wrong number of arguments provided for static config plugin, expected either 1 or 2, got ${plugin.length}`\n );\n return plugin;\n }\n return [plugin, undefined];\n}\n\nexport function assertInternalProjectRoot(projectRoot?: string): asserts projectRoot {\n assert(\n projectRoot,\n `Unexpected: Config \\`_internal.projectRoot\\` isn't defined by expo-cli, this is a bug.`\n );\n}\n\n// Resolve the module function and assert type\nexport function resolveConfigPluginFunction(projectRoot: string, pluginReference: string) {\n const { plugin } = resolveConfigPluginFunctionWithInfo(projectRoot, pluginReference);\n return plugin;\n}\n\n// Resolve the module function and assert type\nexport function resolveConfigPluginFunctionWithInfo(projectRoot: string, pluginReference: string) {\n const { filePath: pluginFile, isPluginFile } = resolvePluginForModule(\n projectRoot,\n pluginReference\n );\n let result: any;\n try {\n result = requirePluginFile(pluginFile);\n } catch (error) {\n if (error instanceof SyntaxError) {\n const learnMoreLink = `Learn more: https://docs.expo.dev/guides/config-plugins/#creating-a-plugin`;\n // If the plugin reference is a node module, and that node module has a syntax error, then it probably doesn't have an official config plugin.\n if (!isPluginFile && !moduleNameIsDirectFileReference(pluginReference)) {\n const pluginError = new PluginError(\n `Package \"${pluginReference}\" does not contain a valid config plugin.\\n${learnMoreLink}\\n\\n${error.message}`,\n 'INVALID_PLUGIN_IMPORT'\n );\n pluginError.stack = error.stack;\n throw pluginError;\n }\n }\n throw error;\n }\n\n const plugin = resolveConfigPluginExport({\n plugin: result,\n pluginFile,\n pluginReference,\n isPluginFile,\n });\n return { plugin, pluginFile, pluginReference, isPluginFile };\n}\n\n/**\n * - Resolve the exported contents of an Expo config (be it default or module.exports)\n * - Assert no promise exports\n * - Return config type\n * - Serialize config\n *\n * @param props.plugin plugin results\n * @param props.pluginFile plugin file path\n * @param props.pluginReference the string used to reference the plugin\n * @param props.isPluginFile is file path from the app.plugin.js module root\n */\nexport function resolveConfigPluginExport({\n plugin,\n pluginFile,\n pluginReference,\n isPluginFile,\n}: {\n plugin: any;\n pluginFile: string;\n pluginReference: string;\n isPluginFile: boolean;\n}): ConfigPlugin<unknown> {\n if (plugin.default != null) {\n plugin = plugin.default;\n }\n if (typeof plugin !== 'function') {\n const learnMoreLink = `Learn more: https://docs.expo.dev/guides/config-plugins/#creating-a-plugin`;\n // If the plugin reference is a node module, and that node module does not export a function then it probably doesn't have a config plugin.\n if (!isPluginFile && !moduleNameIsDirectFileReference(pluginReference)) {\n throw new PluginError(\n `Package \"${pluginReference}\" does not contain a valid config plugin. Module must export a function from file: ${pluginFile}\\n${learnMoreLink}`,\n 'INVALID_PLUGIN_TYPE'\n );\n }\n throw new PluginError(\n `Plugin \"${pluginReference}\" must export a function from file: ${pluginFile}. ${learnMoreLink}`,\n 'INVALID_PLUGIN_TYPE'\n );\n }\n\n return plugin;\n}\n\nfunction requirePluginFile(filePath: string): any {\n try {\n return require(filePath);\n } catch (error) {\n // TODO: Improve error messages\n throw error;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,sBAAA,CAAAC,OAAA;EAAAH,OAAA,YAAAA,CAAA;IAAA,OAAAC,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9B,eAAe;IAAEK;EAAa,CAAC;AAC9D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASkC,yBAAyBA,CAAC;EACxCjB,MAAM;EACNQ,UAAU;EACV9B,eAAe;EACfK;AAMF,CAAC,EAAyB;EACxB,IAAIiB,MAAM,CAACxC,OAAO,IAAI,IAAI,EAAE;IAC1BwC,MAAM,GAAGA,MAAM,CAACxC,OAAO;EACzB;EACA,IAAI,OAAOwC,MAAM,KAAK,UAAU,EAAE;IAChC,MAAMa,aAAa,GAAG,4EAA4E;IAClG;IACA,IAAI,CAAC9B,YAAY,IAAI,CAACJ,+BAA+B,CAACD,eAAe,CAAC,EAAE;MACtE,MAAM,KAAIa,qBAAW,EACnB,YAAYb,eAAe,sFAAsF8B,UAAU,KAAKK,aAAa,EAAE,EAC/I,qBACF,CAAC;IACH;IACA,MAAM,KAAItB,qBAAW,EACnB,WAAWb,eAAe,uCAAuC8B,UAAU,KAAKK,aAAa,EAAE,EAC/F,qBACF,CAAC;EACH;EAEA,OAAOb,MAAM;AACf;AAEA,SAASU,iBAAiBA,CAACxB,QAAgB,EAAO;EAChD,IAAI;IACF,OAAOtC,OAAO,CAACsC,QAAQ,CAAC;EAC1B,CAAC,CAAC,OAAOyB,KAAK,EAAE;IACd;IACA,MAAMA,KAAK;EACb;AACF","ignoreList":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@expo/config-plugins",
3
- "version": "9.0.9",
3
+ "version": "9.0.10",
4
4
  "description": "A library for Expo config plugins",
5
5
  "main": "build/index.js",
6
6
  "scripts": {
@@ -57,5 +57,5 @@
57
57
  "publishConfig": {
58
58
  "access": "public"
59
59
  },
60
- "gitHead": "68c2c4f5a536c4eb7db9551188c7f667d9fa53c8"
60
+ "gitHead": "8b7a5da5dc407c5242f4c512e892c2ca3506a096"
61
61
  }