Fix generation of bundled.json, make source maps work in prod builds
Summary: This diff fixes several issues around loading plugin, such as: * make suresource maps work in the flipper-server production build * make sure default plugins are no symlinked, which wouldn't work anywhere else but on the the system where it was build * support release channel param for flipper-server Bundled flipper-server is now 42MB (with icons (see later diffs) and plugins ``` ll flipper-server-v0.0.0.tgz -rw-r--r-- 1 mweststrate staff 42M 23 Dec 15:29 flipper-server-v0.0.0.tgz ``` Reviewed By: nikoant Differential Revision: D33294677 fbshipit-source-id: 63538dc8127f883fee6a3608673ad11ce239b350
This commit is contained in:
committed by
Facebook GitHub Bot
parent
b1d960e4c4
commit
72fa481d27
@@ -59,10 +59,18 @@ export function initializeRenderHost(
|
||||
},
|
||||
flipperServer,
|
||||
async requirePlugin(path) {
|
||||
// TODO: use `await import(path)`?
|
||||
const source = await flipperServer.exec('plugin-source', path);
|
||||
// eslint-disable-next-line no-new-func
|
||||
const cjsLoader = new Function('module', source);
|
||||
let source = await flipperServer.exec('plugin-source', path);
|
||||
// append source url (to make sure a file entry shows up in the debugger)
|
||||
source += `\n//# sourceURL=file://${path}`;
|
||||
// and source map url (to get source code if available)
|
||||
source += `\n//# sourceMappingURL=file://${path.replace(/.js$/, '.map')}`;
|
||||
|
||||
// Plugins are compiled as typical CJS modules, referring to the global
|
||||
// 'module', which we'll make available by loading the source into a closure that captures 'module'.
|
||||
// Note that we use 'eval', and not 'new Function', because the latter will cause the source maps
|
||||
// to be off by two lines (as the function declaration uses two lines in the generated source)
|
||||
// eslint-disable-next-line no-eval
|
||||
const cjsLoader = eval('(module) => {' + source + '\n}');
|
||||
const theModule = {exports: {}};
|
||||
cjsLoader(theModule);
|
||||
return theModule.exports;
|
||||
|
||||
Reference in New Issue
Block a user