Skip to content

Commit aae5ace

Browse files
committed
fix-next(preview): externalize all plugins from the Preview app
Mark all plugins that are already in the Preview app as external. This will prevent webpack from bundling them. Having two instances of one plugin, may cause problems.
1 parent 5a0cd18 commit aae5ace

File tree

2 files changed

+8
-58
lines changed

2 files changed

+8
-58
lines changed

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

+3-9
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,9 @@ 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-
// The core theme links are custom and should be handled by us build time.
38-
.filter(plugin => !_.includes(["nativescript-theme-core"], plugin));
39-
40-
result.push(
41-
"tns-core-modules",
42-
"tns-core-modules-widgets",
43-
"@angular"
44-
);
36+
// The core theme links are custom and
37+
// should be handled by webpack during build.
38+
.filter(plugin => plugin !== "nativescript-theme-core");
4539

4640
return result;
4741
}

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`, `tns-core-modules-widgets` and `@angular`) when no plugins are provided",
421-
plugins: {},
422-
expectedPlugins: ["tns-core-modules", "tns-core-modules-widgets", "@angular"]
423-
},
424-
{
425-
name: "should include `nativescript-vue`",
426-
plugins: { "nativescript-vue": "1.2.3" },
427-
expectedPlugins: ["nativescript-vue", "tns-core-modules", "tns-core-modules-widgets", "@angular"]
428-
},
429-
{
430-
name: "should include `nativescript-intl`",
431-
plugins: { "nativescript-intl": "4.5.6" },
432-
expectedPlugins: ["nativescript-intl", "tns-core-modules", "tns-core-modules-widgets", "@angular"]
433-
},
434-
{
435-
name: "should include `nativescript-angular`",
436-
plugins: { "nativescript-angular": "7.8.9" },
437-
expectedPlugins: ["nativescript-angular", "tns-core-modules", "tns-core-modules-widgets", "@angular"]
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", "@angular"]
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", "@angular"]
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", "@angular"]
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)