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

Implement new APIs for inter-plugin communication #3807

Merged
merged 20 commits into from
Oct 8, 2020
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
201 changes: 184 additions & 17 deletions docs/05-plugin-development.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/999-big-list-of-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ manualChunks(id) {

Be aware that manual chunks can change the behaviour of the application if side-effects are triggered before the corresponding modules are actually used.

When using the function form, `manualChunks` will be passed an object as second parameter containing the functions `getModuleInfo` and `getModuleIds` that work the same way as [`this.getModuleInfo`](guide/en/#thisgetmoduleinfomoduleid-string--moduleinfo) and [`this.getModuleIds`](guide/en/#thisgetmoduleids--iterableiteratorstring) on the plugin context.
When using the function form, `manualChunks` will be passed an object as second parameter containing the functions `getModuleInfo` and `getModuleIds` that work the same way as [`this.getModuleInfo`](guide/en/#thisgetmoduleinfomoduleid-string--moduleinfo--null) and [`this.getModuleIds`](guide/en/#thisgetmoduleids--iterableiteratorstring) on the plugin context.

This can be used to dynamically determine into which manual chunk a module should be placed depending on its position in the module graph. For instance consider a scenario where you have a set of components, each of which dynamically imports a set of translated strings, i.e.

Expand Down
112 changes: 53 additions & 59 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 11 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
"devDependencies": {
"@rollup/plugin-alias": "^3.1.1",
"@rollup/plugin-buble": "^0.21.3",
"@rollup/plugin-commonjs": "^15.0.0",
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-replace": "^2.3.3",
Expand All @@ -75,7 +75,7 @@
"@types/require-relative": "^0.8.0",
"@types/signal-exit": "^3.0.0",
"@types/yargs-parser": "^15.0.0",
"acorn": "^8.0.1",
"acorn": "^8.0.3",
"acorn-class-fields": "^0.3.7",
"acorn-jsx": "^5.3.1",
"acorn-numeric-separator": "^0.3.6",
Expand All @@ -90,27 +90,27 @@
"date-time": "^3.1.0",
"es5-shim": "^4.5.14",
"es6-shim": "^0.35.5",
"eslint": "^7.9.0",
"eslint-plugin-import": "^2.22.0",
"eslint": "^7.10.0",
"eslint-plugin-import": "^2.22.1",
"execa": "^4.0.3",
"fixturify": "^2.1.0",
"hash.js": "^1.1.7",
"husky": "^4.3.0",
"is-reference": "^1.2.1",
"lint-staged": "^10.3.0",
"lint-staged": "^10.4.0",
"locate-character": "^2.0.5",
"magic-string": "^0.25.7",
"markdownlint-cli": "^0.23.2",
"markdownlint-cli": "^0.24.0",
"micromatch": "^4.0.2",
"mocha": "^8.1.3",
"node-fetch": "^2.6.1",
"nyc": "^15.1.0",
"prettier": "^2.1.2",
"pretty-bytes": "^5.4.1",
"pretty-ms": "^7.0.0",
"pretty-ms": "^7.0.1",
"require-relative": "^0.8.7",
"requirejs": "^2.3.6",
"rollup": "^2.26.11",
"rollup": "^2.28.2",
"rollup-plugin-license": "^2.2.0",
"rollup-plugin-string": "^3.0.0",
"rollup-plugin-terser": "^7.0.2",
Expand All @@ -124,12 +124,12 @@
"source-map-support": "^0.5.19",
"sourcemap-codec": "^1.4.8",
"systemjs": "^6.6.1",
"terser": "^5.3.1",
"terser": "^5.3.4",
"tslib": "^2.0.1",
"tslint": "^6.1.3",
"typescript": "^4.0.2",
"typescript": "^4.0.3",
"url-parse": "^1.4.7",
"yargs-parser": "^20.0.0"
"yargs-parser": "^20.2.1"
},
"files": [
"dist/**/*.js",
Expand Down
13 changes: 8 additions & 5 deletions src/ExternalModule.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import ExternalVariable from './ast/variables/ExternalVariable';
import { NormalizedInputOptions, NormalizedOutputOptions } from './rollup/types';
import {
CustomPluginOptions,
NormalizedInputOptions,
NormalizedOutputOptions
} from './rollup/types';
import { makeLegal } from './utils/identifierHelpers';
import { isAbsolute, normalize, relative } from './utils/path';

Expand All @@ -10,9 +14,7 @@ export default class ExternalModule {
dynamicImporters: string[] = [];
execIndex: number;
exportedVariables: Map<ExternalVariable, string>;
id: string;
importers: string[] = [];
moduleSideEffects: boolean | 'no-treeshake';
mostCommonSuggestion = 0;
namespaceVariableName = '';
nameSuggestions: { [name: string]: number };
Expand All @@ -25,8 +27,9 @@ export default class ExternalModule {

constructor(
private readonly options: NormalizedInputOptions,
id: string,
moduleSideEffects: boolean | 'no-treeshake'
public readonly id: string,
public moduleSideEffects: boolean | 'no-treeshake',
public meta: CustomPluginOptions
) {
this.id = id;
this.execIndex = Infinity;
Expand Down