Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions 9 lib/controllers/prepare-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ export class PrepareController extends EventEmitter {
};
}

await this.writeRuntimePackageJson(projectData, platformData);
await this.writeRuntimePackageJson(projectData, platformData, prepareData);

await this.$projectChangesService.savePrepareInfo(
platformData,
Expand Down Expand Up @@ -433,7 +433,8 @@ export class PrepareController extends EventEmitter {
*/
public async writeRuntimePackageJson(
projectData: IProjectData,
platformData: IPlatformData
platformData: IPlatformData,
prepareData: IPrepareData = null
) {
const configInfo = this.$projectConfigService.detectProjectConfigs(
projectData.projectDir
Expand Down Expand Up @@ -509,6 +510,10 @@ export class PrepareController extends EventEmitter {
);
}

if (prepareData?.uniqueBundle) {
packageData.main = `${packageData.main}.${prepareData.uniqueBundle}`;
}

this.$fs.writeJson(packagePath, packageData);
}

Expand Down
3 changes: 3 additions & 0 deletions 3 lib/data/prepare-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export class PrepareData extends ControllerDataBase {
public watch?: boolean;
public watchNative: boolean = true;
public hostProjectPath?: string;
public uniqueBundle: number;

constructor(
public projectDir: string,
Expand Down Expand Up @@ -43,6 +44,8 @@ export class PrepareData extends ControllerDataBase {
this.watchNative = data.watchNative;
}
this.hostProjectPath = data.hostProjectPath;

this.uniqueBundle = !this.watch && data.uniqueBundle ? Date.now() : 0;
}
}

Expand Down
2 changes: 1 addition & 1 deletion 2 lib/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ interface IOptions
dryRun: boolean;

platformOverride: string;

uniqueBundle: boolean;
// allow arbitrary options
[optionName: string]: any;
}
Expand Down
2 changes: 2 additions & 0 deletions 2 lib/definitions/prepare.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ declare global {

// embedding
hostProjectPath?: string;

uniqueBundle: number;
}

interface IiOSCodeSigningData {
Expand Down
1 change: 1 addition & 0 deletions 1 lib/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,7 @@ export class Options {
default: true,
},
dryRun: { type: OptionType.Boolean, hasSensitiveValue: false },
uniqueBundle: { type: OptionType.Boolean, hasSensitiveValue: false },
};
}

Expand Down
4 changes: 4 additions & 0 deletions 4 lib/services/webpack/webpack-compiler-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,10 @@ export class WebpackCompilerService
envData.sourceMap = envData.sourceMap === "true";
}

if (prepareData.uniqueBundle > 0) {
envData.uniqueBundle = prepareData.uniqueBundle;
}

return envData;
}

Expand Down
21 changes: 9 additions & 12 deletions 21 test/controllers/prepare-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const prepareData = {
env: {},
watch: true,
watchNative: true,
uniqueBundle: 0,
};

let isCompileWithWatchCalled = false;
Expand Down Expand Up @@ -72,9 +73,8 @@ function createTestInjector(data: { hasNativeChanges: boolean }): IInjector {
},
});

const prepareController: PrepareController = injector.resolve(
"prepareController"
);
const prepareController: PrepareController =
injector.resolve("prepareController");
prepareController.emit = (eventName: string, eventData: any) => {
emittedEventNames.push(eventName);
emittedEventData.push(eventData);
Expand Down Expand Up @@ -103,9 +103,8 @@ describe("prepareController", () => {
it(`should execute native prepare and webpack's compilation for ${platform} platform when hasNativeChanges is ${hasNativeChanges}`, async () => {
const injector = createTestInjector({ hasNativeChanges });

const prepareController: PrepareController = injector.resolve(
"prepareController"
);
const prepareController: PrepareController =
injector.resolve("prepareController");
await prepareController.prepare({ ...prepareData, platform });

assert.isTrue(isCompileWithWatchCalled);
Expand All @@ -116,9 +115,8 @@ describe("prepareController", () => {
it(`should respect native changes that are made before the initial preparation of the project had been done for ${platform}`, async () => {
const injector = createTestInjector({ hasNativeChanges: false });

const prepareController: PrepareController = injector.resolve(
"prepareController"
);
const prepareController: PrepareController =
injector.resolve("prepareController");

const prepareNativePlatformService = injector.resolve(
"prepareNativePlatformService"
Expand Down Expand Up @@ -158,9 +156,8 @@ describe("prepareController", () => {
it("shouldn't start the watcher when watch is false", async () => {
const injector = createTestInjector({ hasNativeChanges: false });

const prepareController: PrepareController = injector.resolve(
"prepareController"
);
const prepareController: PrepareController =
injector.resolve("prepareController");
await prepareController.prepare({
...prepareData,
watch: false,
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.