Open MaxAst opened 9 months ago
potential solution: https://github.com/expo/fyi/blob/main/absolute-path-expo-modules.md
Hi @MaxAst, besides the error on the aliases, does the build through EAS work? have you already tried a compilation?
Thanks in advance
Hey @Remeic, yes, besides the alias error EAS works like a charme with this plugin
@MaxAst seconding this issue
@MaxAst actually, I figured out a solution here. Made this change to my metro.config.js
:
// Learn more https://docs.expo.io/guides/customizing-metro
// const { getSentryExpoConfig } = require("@sentry/react-native/metro");
const { getDefaultConfig } = require("expo/metro-config");
const path = require("path");
/**
* Add support for share.js as a recognized extension to the Metro config.
* This allows creating an index.share.js entry point for our iOS share extension
*
* @param {import('expo/metro-config').MetroConfig} config
* @returns {import('expo/metro-config').MetroConfig}
*/
function withShareExtension(config) {
config.resolver.resolveRequest = (context, moduleName, platform) => {
// Checking if module name starts with '@'
if (moduleName.startsWith("@/")) {
// Replacing '@' with absolute path
moduleName = moduleName.replace("@", path.resolve(__dirname));
}
return context.resolveRequest(context, moduleName, platform);
};
config.transformer.getTransformOptions = () => ({
resolver: {
sourceExts: [...config.resolver.sourceExts, "share.js"], // Add 'share.js' as a recognized extension
},
});
return config;
}
module.exports = withShareExtension(
getDefaultConfig(__dirname, {
// [Web-only]: Enables CSS support in Metro.
isCSSEnabled: true,
}),
);
nice @chris-sark! I'll give this a try later
@MaxAst sounds good! if you could provide any insight into how to use .env variables that would be extremely useful as well: https://github.com/MaxAst/expo-share-extension/issues/45
@chris-sark Thanks for that alias fix. Worked great for me.
from the XCode logs:
Tried adding
babel-plugin-module-resolver
, but that didn't help. Need to figure out how Expo does this behind the scenes and adapt it to when paths for the share extension target are resolved.