Skip to content

Commonjs plus globals default export#2261

Merged
marvinhagemeister merged 7 commits intomasterfrom
commonjs-plus-globals-default-export
Jun 18, 2020
Merged

Commonjs plus globals default export#2261
marvinhagemeister merged 7 commits intomasterfrom
commonjs-plus-globals-default-export

Conversation

@developit
Copy link
Copy Markdown
Member

@developit developit commented Jan 20, 2020

This changes preact.min.js to be a file that can be used either as CommonJS or as browser globals, by "exporting" preact using the following format, which is essentially what preact.min.js included in Preact 8 and prior.

(function() {
    if (typeof module < "u") module.exports = preact;
    else self.preact = preact;
})()

Note: typeof module < "u" is a shortened version of typeof module !== "undefined".

The standard dist/preact.js remains a pure CommonJS module.

Fixes #2009.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Feb 18, 2020

Size Change: +19 B (0%)

Total Size: 39.7 kB

Filename Size Change
dist/preact.min.js 3.9 kB +19 B (0%)
ℹ️ View Unchanged
Filename Size Change
compat/dist/compat.js 3.2 kB 0 B
compat/dist/compat.module.js 3.23 kB 0 B
compat/dist/compat.umd.js 3.25 kB 0 B
debug/dist/debug.js 2.99 kB 0 B
debug/dist/debug.module.js 2.98 kB 0 B
debug/dist/debug.umd.js 3.08 kB 0 B
devtools/dist/devtools.js 184 B 0 B
devtools/dist/devtools.module.js 195 B 0 B
devtools/dist/devtools.umd.js 260 B 0 B
dist/preact.js 3.88 kB 0 B
dist/preact.module.js 3.89 kB 0 B
dist/preact.umd.js 3.93 kB 0 B
hooks/dist/hooks.js 1.09 kB 0 B
hooks/dist/hooks.module.js 1.11 kB 0 B
hooks/dist/hooks.umd.js 1.17 kB 0 B
test-utils/dist/testUtils.js 437 B 0 B
test-utils/dist/testUtils.module.js 439 B 0 B
test-utils/dist/testUtils.umd.js 515 B 0 B

compressed-size-action

@coveralls
Copy link
Copy Markdown

coveralls commented Feb 18, 2020

Coverage Status

Coverage remained the same at 99.8% when pulling 01ad9a1 on commonjs-plus-globals-default-export into a299d1d on master.

@developit developit force-pushed the commonjs-plus-globals-default-export branch from 01ad9a1 to 762ae6d Compare June 17, 2020 18:19
@developit developit marked this pull request as ready for review June 17, 2020 18:19
@marvinhagemeister marvinhagemeister merged commit 401f71c into master Jun 18, 2020
@marvinhagemeister marvinhagemeister deleted the commonjs-plus-globals-default-export branch June 18, 2020 06:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Preact undefined in version 10, but not earlier versions

4 participants