Skip to content

Commit d3f99f5

Browse files
authored
Merge pull request #4004 from NativeScript/sis0k0/preview-externalize-angular
fix-next(preview): externalize all plugins from the Preview app
2 parents fd8a83a + aae5ace commit d3f99f5

File tree

2 files changed

+9
-58
lines changed

2 files changed

+9
-58
lines changed

lib/services/livesync/playground/preview-app-plugins-service.ts

+4-9
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,10 @@ export class PreviewAppPluginsService implements IPreviewAppPluginsService {
3333
public getExternalPlugins(device: Device): string[] {
3434
const devicePlugins = this.getDevicePlugins(device);
3535
const result = _.keys(devicePlugins)
36-
.filter(plugin => plugin.indexOf("nativescript") !== -1)
37-
// exclude angular and vue related dependencies as they do not contain
38-
// any native code. In this way, we will read them from the bundle
39-
// and improve the app startup time by not reading a lot of
40-
// files from the file system instead. Also, the core theme links
41-
// are custom and should be handled by us build time.
42-
.filter(plugin => !_.includes(["nativescript-angular", "nativescript-vue", "nativescript-intl", "nativescript-theme-core"], plugin));
43-
44-
result.push(...["tns-core-modules", "tns-core-modules-widgets"]);
36+
// The core theme links are custom and
37+
// should be handled by webpack during build.
38+
.filter(plugin => plugin !== "nativescript-theme-core");
39+
4540
return result;
4641
}
4742

test/services/playground/preview-app-plugins-service.ts

+5-49
Original file line numberDiff line numberDiff line change
@@ -415,55 +415,11 @@ describe("previewAppPluginsService", () => {
415415
});
416416
});
417417
describe("getExternalPlugins", () => {
418-
const testCases = [
419-
{
420-
name: "should return default plugins(`tns-core-modules` and `tns-core-modules-widgets`) when no plugins are provided",
421-
plugins: {},
422-
expectedPlugins: ["tns-core-modules", "tns-core-modules-widgets"]
423-
},
424-
{
425-
name: "should exclude `nativescript-vue`",
426-
plugins: { "nativescript-vue": "1.2.3" },
427-
expectedPlugins: ["tns-core-modules", "tns-core-modules-widgets"]
428-
},
429-
{
430-
name: "should exclude `nativescript-intl`",
431-
plugins: { "nativescript-intl": "4.5.6" },
432-
expectedPlugins: ["tns-core-modules", "tns-core-modules-widgets"]
433-
},
434-
{
435-
name: "should exclude `nativescript-angular`",
436-
plugins: { "nativescript-angular": "7.8.9" },
437-
expectedPlugins: ["tns-core-modules", "tns-core-modules-widgets"]
438-
},
439-
{
440-
name: "should exclude `nativescript-theme-core`",
441-
plugins: { "nativescript-theme-core": "1.3.5" },
442-
expectedPlugins: ["tns-core-modules", "tns-core-modules-widgets"]
443-
},
444-
{
445-
name: "should return plugins that contain `nativescript` in their names",
446-
plugins: {
447-
"nativescript-facebook": "4.5.6"
448-
},
449-
expectedPlugins: ["nativescript-facebook", "tns-core-modules", "tns-core-modules-widgets"]
450-
},
451-
{
452-
name: "should not return plugins that do not contain `nativescript` in their names",
453-
plugins: {
454-
lodash: "4.5.6",
455-
xmlhttprequest: "1.2.3"
456-
},
457-
expectedPlugins: ["tns-core-modules", "tns-core-modules-widgets"]
458-
}
459-
];
460-
461-
_.each(testCases, testCase => {
462-
it(`${testCase.name}`, () => {
463-
const { previewAppPluginsService, device } = setup(testCase.plugins, testCase.plugins);
464-
const actualPlugins = previewAppPluginsService.getExternalPlugins(device);
465-
assert.deepEqual(actualPlugins, testCase.expectedPlugins);
466-
});
418+
it("should exclude `nativescript-theme-core`", () => {
419+
const plugins = { "nativescript-theme-core": "1.3.5" };
420+
const { previewAppPluginsService, device } = setup(plugins, plugins);
421+
const actualPlugins = previewAppPluginsService.getExternalPlugins(device);
422+
assert.notInclude(actualPlugins, "nativescript-theme-core");
467423
});
468424
});
469425
});

0 commit comments

Comments
 (0)