Correct the publishing and minification of the es6 module
This commit is contained in:
Родитель
bd807140ea
Коммит
ec8f00b58e
|
@ -34,7 +34,7 @@
|
|||
},
|
||||
"@types/estree": {
|
||||
"version": "0.0.39",
|
||||
"from": "@types/estree@0.0.39",
|
||||
"from": "@types/estree@*",
|
||||
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz"
|
||||
},
|
||||
"@types/events": {
|
||||
|
@ -58,15 +58,25 @@
|
|||
"resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-3.0.3.tgz"
|
||||
},
|
||||
"@types/node": {
|
||||
"version": "12.12.7",
|
||||
"version": "12.12.9",
|
||||
"from": "@types/node@*",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.7.tgz"
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.9.tgz"
|
||||
},
|
||||
"@types/resolve": {
|
||||
"version": "0.0.8",
|
||||
"from": "@types/resolve@0.0.8",
|
||||
"resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-0.0.8.tgz"
|
||||
},
|
||||
"abbrev": {
|
||||
"version": "1.1.1",
|
||||
"from": "abbrev@>=1.0.0 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz"
|
||||
},
|
||||
"acorn": {
|
||||
"version": "7.1.0",
|
||||
"from": "acorn@^7.1.0",
|
||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-7.1.0.tgz"
|
||||
},
|
||||
"ajv": {
|
||||
"version": "6.10.2",
|
||||
"from": "ajv@^6.5.5",
|
||||
|
@ -256,9 +266,9 @@
|
|||
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.1.tgz"
|
||||
},
|
||||
"builtin-modules": {
|
||||
"version": "2.0.0",
|
||||
"from": "builtin-modules@>=2.0.0 <3.0.0",
|
||||
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-2.0.0.tgz"
|
||||
"version": "3.1.0",
|
||||
"from": "builtin-modules@^3.1.0",
|
||||
"resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.1.0.tgz"
|
||||
},
|
||||
"cache-base": {
|
||||
"version": "1.0.1",
|
||||
|
@ -956,9 +966,9 @@
|
|||
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz"
|
||||
},
|
||||
"has-symbols": {
|
||||
"version": "1.0.0",
|
||||
"from": "has-symbols@>=1.0.0 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz"
|
||||
"version": "1.0.1",
|
||||
"from": "has-symbols@^1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz"
|
||||
},
|
||||
"has-value": {
|
||||
"version": "1.0.0",
|
||||
|
@ -1765,9 +1775,9 @@
|
|||
}
|
||||
},
|
||||
"rollup": {
|
||||
"version": "0.66.6",
|
||||
"from": "rollup@^0.66.0",
|
||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-0.66.6.tgz"
|
||||
"version": "1.27.2",
|
||||
"from": "rollup@^1.27.2",
|
||||
"resolved": "https://registry.npmjs.org/rollup/-/rollup-1.27.2.tgz"
|
||||
},
|
||||
"rollup-plugin-copy": {
|
||||
"version": "3.1.0",
|
||||
|
@ -1796,10 +1806,32 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"rollup-plugin-minify-es": {
|
||||
"version": "1.1.1",
|
||||
"from": "rollup-plugin-minify-es@>=1.1.1 <2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/rollup-plugin-minify-es/-/rollup-plugin-minify-es-1.1.1.tgz",
|
||||
"dependencies": {
|
||||
"commander": {
|
||||
"version": "2.13.0",
|
||||
"from": "commander@>=2.13.0 <2.14.0",
|
||||
"resolved": "https://registry.npmjs.org/commander/-/commander-2.13.0.tgz"
|
||||
},
|
||||
"source-map": {
|
||||
"version": "0.6.1",
|
||||
"from": "source-map@>=0.6.1 <0.7.0",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz"
|
||||
},
|
||||
"uglify-es": {
|
||||
"version": "3.3.9",
|
||||
"from": "uglify-es@>=3.1.0 <4.0.0",
|
||||
"resolved": "https://registry.npmjs.org/uglify-es/-/uglify-es-3.3.9.tgz"
|
||||
}
|
||||
}
|
||||
},
|
||||
"rollup-plugin-node-resolve": {
|
||||
"version": "3.4.0",
|
||||
"from": "rollup-plugin-node-resolve@^3.4.0",
|
||||
"resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-3.4.0.tgz"
|
||||
"version": "5.2.0",
|
||||
"from": "rollup-plugin-node-resolve@^5.2.0",
|
||||
"resolved": "https://registry.npmjs.org/rollup-plugin-node-resolve/-/rollup-plugin-node-resolve-5.2.0.tgz"
|
||||
},
|
||||
"rollup-plugin-replace": {
|
||||
"version": "2.2.0",
|
||||
|
@ -1813,7 +1845,7 @@
|
|||
},
|
||||
"rollup-pluginutils": {
|
||||
"version": "2.8.2",
|
||||
"from": "rollup-pluginutils@^2.6.0",
|
||||
"from": "rollup-pluginutils@^2.8.1",
|
||||
"resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz"
|
||||
},
|
||||
"run-parallel": {
|
||||
|
|
|
@ -2517,6 +2517,24 @@ img {
|
|||
<p>As with including any additional code into your project there are trade offs that you need to make, including if you are looking at this helper, one of the primary items is the overall size of the additional code that you will be including vs the minification gains that you <em>may</em> obtained. This project endeavours to keep it's impact (bytes) as small as possible while supporting you to create readable and maintainable code that will create a smaller minified output.</p>
|
||||
<p>In most cases when creating JavaScript to support better minfication, when your code doesn't expose or provide a lot of public methods or only uses un-minifiable "names" less than 2 times, then you may not see enough potential gains to counteract the additional bytes required from the helper code. However, for any significant project you should.</p>
|
||||
<p>So at the end of the day, if you are creating JS classes directly you <em>should</em> be able to create a simplier one-off solution that would result in smaller output (total bytes). This is how this project started, but, once we had several of these one-off solutions it made more sense to build it once.</p>
|
||||
<a href="#included-npm-distribution-formats" id="included-npm-distribution-formats" style="color: inherit; text-decoration: none;">
|
||||
<h2>Included NPM distribution formats</h2>
|
||||
</a>
|
||||
<p>As part of the build / publish formats via NPM we include the following module formats:</p>
|
||||
<ul>
|
||||
<li>dist/esm – Used as the "module" definition for npm, which keeps the bundle as an ES module file, suitable for other bundlers and inclusion as a < amd – Asynchronous Module Definition, used with module loaders like RequireJS</li>
|
||||
<li>dist/node - Used as the "main" npm entry point for the utility, using the umd format with any third party modules located and included using the <a href="https://nodejs.org/api/modules.html#modules_all_together">Node resolution algorithm</a></li>
|
||||
</ul>
|
||||
<a href="#other-included-formats" id="other-included-formats" style="color: inherit; text-decoration: none;">
|
||||
<h3>Other included formats</h3>
|
||||
</a>
|
||||
<ul>
|
||||
<li>dist/cjs – CommonJS, suitable for Node and other bundlers
|
||||
script type=module> tag in modern browsers</li>
|
||||
<li>dist/iife – A self-executing function, suitable for inclusion as a <script> tag. (If you want to create a bundle for your application, you probably want to use this.)</li>
|
||||
<li>dist/umd – Universal Module Definition, works as amd, cjs and iife all in one</li>
|
||||
<li>dist/system – Native format of the SystemJS loader</li>
|
||||
</ul>
|
||||
<a href="#browser-support" id="browser-support" style="color: inherit; text-decoration: none;">
|
||||
<h2>Browser Support</h2>
|
||||
</a>
|
||||
|
|
|
@ -2517,6 +2517,24 @@ img {
|
|||
<p>As with including any additional code into your project there are trade offs that you need to make, including if you are looking at this helper, one of the primary items is the overall size of the additional code that you will be including vs the minification gains that you <em>may</em> obtained. This project endeavours to keep it's impact (bytes) as small as possible while supporting you to create readable and maintainable code that will create a smaller minified output.</p>
|
||||
<p>In most cases when creating JavaScript to support better minfication, when your code doesn't expose or provide a lot of public methods or only uses un-minifiable "names" less than 2 times, then you may not see enough potential gains to counteract the additional bytes required from the helper code. However, for any significant project you should.</p>
|
||||
<p>So at the end of the day, if you are creating JS classes directly you <em>should</em> be able to create a simplier one-off solution that would result in smaller output (total bytes). This is how this project started, but, once we had several of these one-off solutions it made more sense to build it once.</p>
|
||||
<a href="#included-npm-distribution-formats" id="included-npm-distribution-formats" style="color: inherit; text-decoration: none;">
|
||||
<h2>Included NPM distribution formats</h2>
|
||||
</a>
|
||||
<p>As part of the build / publish formats via NPM we include the following module formats:</p>
|
||||
<ul>
|
||||
<li>dist/esm – Used as the "module" definition for npm, which keeps the bundle as an ES module file, suitable for other bundlers and inclusion as a < amd – Asynchronous Module Definition, used with module loaders like RequireJS</li>
|
||||
<li>dist/node - Used as the "main" npm entry point for the utility, using the umd format with any third party modules located and included using the <a href="https://nodejs.org/api/modules.html#modules_all_together">Node resolution algorithm</a></li>
|
||||
</ul>
|
||||
<a href="#other-included-formats" id="other-included-formats" style="color: inherit; text-decoration: none;">
|
||||
<h3>Other included formats</h3>
|
||||
</a>
|
||||
<ul>
|
||||
<li>dist/cjs – CommonJS, suitable for Node and other bundlers
|
||||
script type=module> tag in modern browsers</li>
|
||||
<li>dist/iife – A self-executing function, suitable for inclusion as a <script> tag. (If you want to create a bundle for your application, you probably want to use this.)</li>
|
||||
<li>dist/umd – Universal Module Definition, works as amd, cjs and iife all in one</li>
|
||||
<li>dist/system – Native format of the SystemJS loader</li>
|
||||
</ul>
|
||||
<a href="#browser-support" id="browser-support" style="color: inherit; text-decoration: none;">
|
||||
<h2>Browser Support</h2>
|
||||
</a>
|
||||
|
|
|
@ -2414,7 +2414,7 @@ img {
|
|||
<div class="tsd-signature tsd-kind-icon">Dynamic<wbr>Proto<wbr>Delegate<DPType><span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">function</span></div>
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/microsoft/DynamicProto-JS/blob/eba85f2/lib/src/DynamicProto.ts#L318">DynamicProto.ts:318</a></li>
|
||||
<li>Defined in <a href="https://github.com/microsoft/DynamicProto-JS/blob/90f5eec/lib/src/DynamicProto.ts#L318">DynamicProto.ts:318</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
|
@ -2481,7 +2481,7 @@ img {
|
|||
<li class="tsd-description">
|
||||
<aside class="tsd-sources">
|
||||
<ul>
|
||||
<li>Defined in <a href="https://github.com/microsoft/DynamicProto-JS/blob/eba85f2/lib/src/DynamicProto.ts#L371">DynamicProto.ts:371</a></li>
|
||||
<li>Defined in <a href="https://github.com/microsoft/DynamicProto-JS/blob/90f5eec/lib/src/DynamicProto.ts#L371">DynamicProto.ts:371</a></li>
|
||||
</ul>
|
||||
</aside>
|
||||
<div class="tsd-comment tsd-typography">
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@microsoft/dynamicproto-js",
|
||||
"author": "Microsoft Application Insights Team",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"description": "Microsoft Dynamic Proto Utility",
|
||||
"keywords": [
|
||||
"javascript",
|
||||
|
@ -51,10 +51,11 @@
|
|||
"tslint-config-prettier": "^1.18.0",
|
||||
"typescript": "3.7.2",
|
||||
"rollup-plugin-copy": "^3.1.0",
|
||||
"rollup-plugin-node-resolve": "^3.4.0",
|
||||
"rollup-plugin-node-resolve": "^5.2.0",
|
||||
"rollup-plugin-replace": "^2.1.0",
|
||||
"rollup-plugin-uglify": "^6.0.0",
|
||||
"rollup": "^0.66.0"
|
||||
"rollup-plugin-minify-es": "^1.1.1",
|
||||
"rollup": "^1.27.2"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"tslib": "^1.9.3"
|
||||
|
|
|
@ -2,6 +2,7 @@ import nodeResolve from "rollup-plugin-node-resolve";
|
|||
import copy from "rollup-plugin-copy";
|
||||
import {uglify} from "rollup-plugin-uglify";
|
||||
import replace from "rollup-plugin-replace";
|
||||
import minify from 'rollup-plugin-minify-es';
|
||||
|
||||
const version = require("./package.json").version;
|
||||
const inputName = "./out/lib/src/DynamicProto";
|
||||
|
@ -20,7 +21,8 @@ const nodeUmdRollupConfigFactory = (isProduction) => {
|
|||
file: `./dist/node/${outputName}.js`,
|
||||
banner: banner,
|
||||
format: "umd",
|
||||
name: "Microsoft.DynamicProto-JS",
|
||||
name: "Microsoft.DynamicProto-JS",
|
||||
extend: true,
|
||||
sourcemap: true
|
||||
},
|
||||
plugins: [
|
||||
|
@ -71,7 +73,8 @@ const moduleRollupConfigFactory = (format, isProduction) => {
|
|||
file: `./dist/${format}/${outputName}.js`,
|
||||
banner: banner,
|
||||
format: format,
|
||||
name: "Microsoft.DynamicProto-JS",
|
||||
name: "Microsoft.DynamicProto-JS",
|
||||
extend: true,
|
||||
sourcemap: true
|
||||
},
|
||||
plugins: [
|
||||
|
@ -81,26 +84,44 @@ const moduleRollupConfigFactory = (format, isProduction) => {
|
|||
"// Copyright (c) Microsoft Corporation. All rights reserved.": "",
|
||||
"// Licensed under the MIT License.": ""
|
||||
}
|
||||
})
|
||||
}),
|
||||
nodeResolve()
|
||||
]
|
||||
};
|
||||
|
||||
if (isProduction) {
|
||||
moduleRollupConfig.output.file = `./dist/${format}/${outputName}.min.js`;
|
||||
moduleRollupConfig.plugins.push(
|
||||
uglify({
|
||||
ie8: true,
|
||||
toplevel: true,
|
||||
compress: {
|
||||
passes:3,
|
||||
unsafe: true
|
||||
},
|
||||
output: {
|
||||
preamble: banner,
|
||||
webkit:true
|
||||
}
|
||||
})
|
||||
);
|
||||
if (format != "esm") {
|
||||
moduleRollupConfig.plugins.push(
|
||||
uglify({
|
||||
ie8: true,
|
||||
toplevel: true,
|
||||
compress: {
|
||||
passes:3,
|
||||
unsafe: true,
|
||||
},
|
||||
output: {
|
||||
preamble: banner,
|
||||
webkit:true
|
||||
}
|
||||
})
|
||||
);
|
||||
} else {
|
||||
moduleRollupConfig.plugins.push(
|
||||
minify({
|
||||
ie8: true,
|
||||
toplevel: true,
|
||||
compress: {
|
||||
passes:3,
|
||||
unsafe: true,
|
||||
},
|
||||
output: {
|
||||
preamble: banner,
|
||||
webkit:true
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return moduleRollupConfig;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"sourceMap": true,
|
||||
"inlineSources": true,
|
||||
"noImplicitAny": true,
|
||||
"module": "amd",
|
||||
"module": "es6",
|
||||
"moduleResolution": "node",
|
||||
"target": "es3",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@microsoft/dynamicproto-js",
|
||||
"description": "Microsoft Dynamic Proto Utility",
|
||||
"version": "0.1.0",
|
||||
"version": "0.2.0",
|
||||
"keywords": [
|
||||
"javascript",
|
||||
"dynamic prototype",
|
||||
|
@ -40,7 +40,7 @@
|
|||
"grunt-run": "^0.8.1",
|
||||
"grunt-ts": "^6.0.0-beta.22",
|
||||
"grunt-tslint": "^5.0.2",
|
||||
"rollup": "^0.66.0",
|
||||
"rollup": "^1.27.2",
|
||||
"tslint": "^5.19.0",
|
||||
"tslint-config-prettier": "^1.18.0",
|
||||
"tslint-microsoft-contrib": "^5.2.1",
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"sourceMap": true,
|
||||
"inlineSources": true,
|
||||
"noImplicitAny": true,
|
||||
"module": "amd",
|
||||
"module": "es6",
|
||||
"target": "es3",
|
||||
"alwaysStrict": true,
|
||||
"declaration": true
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
"sourceMap": true,
|
||||
"inlineSources": true,
|
||||
"noImplicitAny": true,
|
||||
"module": "amd",
|
||||
"module": "es6",
|
||||
"target": "es3",
|
||||
"alwaysStrict": true
|
||||
},
|
||||
|
|
Загрузка…
Ссылка в новой задаче