Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix isIncluded error when using rollup-plugin-typescript2 #4725

Merged
merged 3 commits into from Nov 27, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/Module.ts
Expand Up @@ -685,8 +685,12 @@ export default class Module {
this.includeAllExports(false);
}

isIncluded(): boolean {
return this.ast!.included || this.namespace.included || this.importedFromNotTreeshaken;
isIncluded(): boolean | null {
// Modules where this.ast is missing have been loaded via this.load and are
// not yet fully processed, hence they cannot be included.
return (
this.ast && (this.ast.included || this.namespace.included || this.importedFromNotTreeshaken)
);
}

linkImports(): void {
Expand Down
23 changes: 23 additions & 0 deletions test/function/samples/preload-after-build/_config.js
@@ -0,0 +1,23 @@
const path = require('node:path');

module.exports = {
description: 'supports this.load() in buildEnd and renderStart',
options: {
plugins: [
{
name: 'test',
buildEnd() {
this.load({ id: path.join(__dirname, 'other2.js') });
},
moduleParsed({ id }) {
if (id.endsWith('main.js')) {
this.load({ id: path.join(__dirname, 'other1.js') });
}
},
renderStart() {
this.load({ id: path.join(__dirname, 'other3.js') });
}
}
]
}
};
1 change: 1 addition & 0 deletions test/function/samples/preload-after-build/main.js
@@ -0,0 +1 @@
assert.ok(true);
1 change: 1 addition & 0 deletions test/function/samples/preload-after-build/other1.js
@@ -0,0 +1 @@
assert.ok(true);
1 change: 1 addition & 0 deletions test/function/samples/preload-after-build/other2.js
@@ -0,0 +1 @@
assert.ok(true);
1 change: 1 addition & 0 deletions test/function/samples/preload-after-build/other3.js
@@ -0,0 +1 @@
assert.ok(true);