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

System format optional setters #3592

Merged
merged 5 commits into from
May 27, 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
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# rollup changelog

## 2.11.0
*2020-05-27*

### Features
* Provide a normalized set of options with proper default values to `buildStart` and `renderStart` (#3597)
* Do not count adding properties to the prototype of an unused class as a side-effect (#3598)

### Bug Fixes
* Do not fail when using a `/*#__PURE__*/` annotation inside a class field (#3599)
* Allow using `--watch` and `--treeshake` together with sub-options such as `--watch.clearScreen` on the command line (#3597)

### Pull Requests
* [#3597](https://github.com/rollup/rollup/pull/3597): Provide normalized options (@lukastaegert)
* [#3598](https://github.com/rollup/rollup/pull/3598): Treeshake prototype modifications in classes (@lukastaegert)
* [#3599](https://github.com/rollup/rollup/pull/3599): Retain pure annotations in class fields (@lukastaegert)
* [#3601](https://github.com/rollup/rollup/pull/3601): Fix white-space in docs (@tu4mo)

## 2.10.9
*2020-05-24*

Expand Down
1 change: 1 addition & 0 deletions cli/help.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ Basic options:
--no-stdin do not read "-" from stdin
--no-strict Don't emit `"use strict";` in the generated modules
--strictDeprecations Throw errors for deprecated features
--systemNullSetters Replace empty SystemJS setters with `null`
--no-treeshake Disable tree-shaking optimisations
--no-treeshake.annotations Ignore pure call annotations
--no-treeshake.moduleSideEffects Assume modules have no side-effects
Expand Down
4 changes: 3 additions & 1 deletion docs/01-command-line-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ export default { // can be an array (for multiple inputs)
namespaceToStringTag,
noConflict,
preferConst,
strict
strict,
systemNullSetters
},

watch: {
Expand Down Expand Up @@ -310,6 +311,7 @@ Many options have command line equivalents. In those cases, any arguments passed
--no-stdin do not read "-" from stdin
--no-strict Don't emit `"use strict";` in the generated modules
--strictDeprecations Throw errors for deprecated features
--systemNullSetters Replace empty SystemJS setters with `null`
--no-treeshake Disable tree-shaking optimisations
--no-treeshake.annotations Ignore pure call annotations
--no-treeshake.moduleSideEffects Assume modules have no side-effects
Expand Down
3 changes: 2 additions & 1 deletion docs/02-javascript-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,8 @@ const outputOptions = {
namespaceToStringTag,
noConflict,
preferConst,
strict
strict,
systemNullSetters
};
```

Expand Down
7 changes: 7 additions & 0 deletions docs/999-big-list-of-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,13 @@ Default: `true`

Whether to include the 'use strict' pragma at the top of generated non-ES bundles. Strictly speaking, ES modules are *always* in strict mode, so you shouldn't disable this without good reason.

#### output.systemNullSetters
Type: `boolean`<br>
CLI: `--systemNullSetters`/`--no-systemNullSetters`<br>
Default: `false`

When outputting the `system` module format, this will replace empty setter functions with `null` as an output simplification. This is *only supported in SystemJS 6.3.3 and above*.

#### preserveSymlinks
Type: `boolean`<br>
CLI: `--preserveSymlinks`<br>
Expand Down
2 changes: 2 additions & 0 deletions src/finalisers/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ export default function system(
.map(s =>
s
? `function${_}(module)${_}{${n}${t}${t}${t}${s}${n}${t}${t}}`
: options.systemNullSetters
? `null`
: `function${_}()${_}{}`
)
.join(`,${_}`)}],`
Expand Down
2 changes: 2 additions & 0 deletions src/rollup/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ export interface OutputOptions {
sourcemapFile?: string;
sourcemapPathTransform?: (sourcePath: string) => string;
strict?: boolean;
systemNullSetters?: boolean;
}

export interface NormalizedOutputOptions {
Expand Down Expand Up @@ -608,6 +609,7 @@ export interface NormalizedOutputOptions {
sourcemapFile: string | undefined;
sourcemapPathTransform: ((sourcePath: string) => string) | undefined;
strict: boolean;
systemNullSetters: boolean;
}

export type WarningHandlerWithDefault = (
Expand Down
3 changes: 2 additions & 1 deletion src/utils/options/mergeOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ function mergeOutputOptions(
sourcemapExcludeSources: getOption('sourcemapExcludeSources'),
sourcemapFile: getOption('sourcemapFile'),
sourcemapPathTransform: getOption('sourcemapPathTransform'),
strict: getOption('strict')
strict: getOption('strict'),
systemNullSetters: getOption('systemNullSetters')
};

warnUnknownOptions(config, Object.keys(outputOptions), 'output options', warn);
Expand Down
3 changes: 2 additions & 1 deletion src/utils/options/normalizeOutputOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ export function normalizeOutputOptions(
sourcemapPathTransform: config.sourcemapPathTransform as
| ((sourcePath: string) => string)
| undefined,
strict: (config.strict as boolean | undefined) ?? true
strict: (config.strict as boolean | undefined) ?? true,
systemNullSetters: (config.systemNullSetters as boolean | undefined) || false
};

warnUnknownOptions(config, Object.keys(outputOptions), 'output options', inputOptions.onwarn);
Expand Down
3 changes: 2 additions & 1 deletion test/form/samples/unused-import/_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ module.exports = {
options: {
external: ['external'],
output: {
globals: { external: 'external' }
globals: { external: 'external' },
systemNullSetters: true
}
}
};
2 changes: 1 addition & 1 deletion test/form/samples/unused-import/_expected/system.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
System.register(['external'], function () {
'use strict';
return {
setters: [function () {}],
setters: [null],
execute: function () {


Expand Down
3 changes: 2 additions & 1 deletion test/hooks/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ describe('hooks', () => {
preferConst: false,
sourcemap: false,
sourcemapExcludeSources: false,
strict: true
strict: true,
systemNullSetters: false
});
assert.strictEqual(options.banner(), 'new banner');
},
Expand Down
4 changes: 2 additions & 2 deletions test/misc/optionList.js

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