I'm using Angular 14 and module federation. I want to use import.meta within my remote application to get the absolute path (e.g. starting with "http://") of a resource. In my remote application, I have webpack.config.js configured like so
module.exports = withModuleFederationPlugin({
name: 'my-app',
exposes: {
'./home':'./src/app/my-module/products.module.ts'
},
shared: {
...shareAll({ singleton: true, strictVersion: true, requiredVersion: 'auto' }),
},
});
Then in my service within the remote application, I try and use import.meta.resolve, like so
@Injectable({
providedIn: 'root'
})
export class MyService {
...
public init() {
const absolutePath = import.meta.resolve('./settings.json');
but this throws the compilation error, "Cannot invoke an object which is possibly 'undefined'.". What is the proper way to invoke the "resolve" method in order to get an absolute path of a resource?