Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lendrik-kumar committed Dec 9, 2024
1 parent ceea0bc commit c6c2af2
Showing 1 changed file with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const legacyPluginIds = [
];

const pathLibrary = require('path');
const punycode = require('punycode/');


export const requireModule = (moduleName: string, fromPluginId: string) => {
if (moduleName === 'path') {
Expand All @@ -18,7 +18,10 @@ export const requireModule = (moduleName: string, fromPluginId: string) => {
if (legacyPluginIds.includes(fromPluginId)) {
if (moduleName === 'punycode') {
console.warn('Requiring punycode is deprecated. Please transition to a newer API.');
return punycode;
return {
toASCII: (domain: string) => new URL(`http://${domain}`).hostname,
toUnicode: (domain: string) => domain,
};
}
if (moduleName === 'fs' || moduleName === 'fs-extra') {
console.warn('The fs library is unavailable to mobile plugins. A non-functional mock will be returned.');
Expand All @@ -36,7 +39,9 @@ export const requireModule = (moduleName: string, fromPluginId: string) => {
return {};
}
if (moduleName === 'url') {
return { parse: (u: string) => new URL(u) };
return {
parse: (u: string) => new URL(u),
};
}
}

Expand Down

0 comments on commit c6c2af2

Please sign in to comment.