Skip to content

Commit

Permalink
fix: preserve @license comments starting with //
Browse files Browse the repository at this point in the history
  • Loading branch information
evilebottnawi authored Apr 25, 2020
1 parent 7105dc3 commit d3f0c81
Show file tree
Hide file tree
Showing 10 changed files with 266 additions and 138 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ jobs:
- name: Lint
run: npm run lint

- name: Security audit
run: npm run security
# - name: Security audit
# run: npm run security

- name: Check commit message
uses: wagoid/commitlint-github-action@v1
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"schema-utils": "^2.6.6",
"serialize-javascript": "^3.0.0",
"source-map": "^0.6.1",
"terser": "^4.6.11",
"terser": "^4.6.12",
"webpack-sources": "^1.4.3"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/minify.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const buildComments = (options, terserOptions, extractedComments) => {
if (condition[key] === 'some') {
condition[key] = (astNode, comment) => {
return (
comment.type === 'comment2' &&
(comment.type === 'comment2' || comment.type === 'comment1') &&
/@preserve|@lic|@cc_on|^\**!/i.test(comment.value)
);
};
Expand Down
10 changes: 5 additions & 5 deletions test/__snapshots__/TerserPlugin.test.js.snap.webpack5
Original file line number Diff line number Diff line change
Expand Up @@ -104,11 +104,11 @@ exports[`TerserPlugin should emit an error on a broken code in parallel mode: wa

exports[`TerserPlugin should regenerate hash: assets 1`] = `
Object {
"598.598.6a72297c2dbf68d09cd0.js": "(window.webpackJsonp=window.webpackJsonp||[]).push([[598],{598:(s,n,p)=>{\\"use strict\\";p.r(n),p.d(n,{default:()=>w});const w=\\"async-dep\\"}}]);",
"AsyncImportExport.a16765ef46535f98a18c.js": "(()=>{\\"use strict\\";var e={},r={};function o(t){if(r[t])return r[t].exports;var n=r[t]={exports:{}};return e[t](n,n.exports,o),n.exports}o.m=e,o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce((r,t)=>(o.f[t](e,r),r),[])),o.u=e=>e+\\".\\"+e+\\".6a72297c2dbf68d09cd0.js\\",o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},o.p=\\"\\",(()=>{var e={988:0};o.f.j=(r,t)=>{var n=o.o(e,r)?e[r]:void 0;if(0!==n)if(n)t.push(n[2]);else{var a=new Promise((o,t)=>{n=e[r]=[o,t]});t.push(n[2]=a);var i,s=o.p+o.u(r),u=document.createElement(\\"script\\");u.charset=\\"utf-8\\",u.timeout=120,o.nc&&u.setAttribute(\\"nonce\\",o.nc),u.src=s;var d=new Error;i=t=>{i=()=>{},u.onerror=u.onload=null,clearTimeout(p);var a=(()=>{if(o.o(e,r)&&(0!==(n=e[r])&&(e[r]=void 0),n))return n[1]})();if(a){var s=t&&(\\"load\\"===t.type?\\"missing\\":t.type),c=t&&t.target&&t.target.src;d.message=\\"Loading chunk \\"+r+\\" failed.\\\\n(\\"+s+\\": \\"+c+\\")\\",d.name=\\"ChunkLoadError\\",d.type=s,d.request=c,a(d)}};var p=setTimeout(()=>{i({type:\\"timeout\\",target:u})},12e4);u.onerror=u.onload=i,document.head.appendChild(u)}};var r=window.webpackJsonp=window.webpackJsonp||[],t=r.push.bind(r);r.push=function(r){for(var t,a,i=r[0],s=r[1],u=r[3],d=0,p=[];d<i.length;d++)a=i[d],o.o(e,a)&&e[a]&&p.push(e[a][0]),e[a]=0;for(t in s)o.o(s,t)&&(o.m[t]=s[t]);for(u&&u(o),n&&n(r);p.length;)p.shift()()};var n=t})(),o.e(598).then(o.bind(o,598)).then(()=>{console.log(\\"Good\\")})})();",
"importExport.5f1adb4803042a573e88.js": "(()=>{\\"use strict\\"})();",
"js.d9ffe80e9d7412c779bf.js": "(()=>{var r={791:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(791)})();",
"mjs.cc652bbdacaa8ea2b17c.js": "(()=>{var r={631:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(631)})();",
"598.598.cf75d036d67393467f48.js": "(window.webpackJsonp=window.webpackJsonp||[]).push([[598],{598:(s,n,p)=>{\\"use strict\\";p.r(n),p.d(n,{default:()=>w});const w=\\"async-dep\\"}}]);",
"AsyncImportExport.d13698984134e1b7ee88.js": "(()=>{\\"use strict\\";var e={},r={};function o(t){if(r[t])return r[t].exports;var n=r[t]={exports:{}};return e[t](n,n.exports,o),n.exports}o.m=e,o.d=(e,r)=>{for(var t in r)o.o(r,t)&&!o.o(e,t)&&Object.defineProperty(e,t,{enumerable:!0,get:r[t]})},o.f={},o.e=e=>Promise.all(Object.keys(o.f).reduce((r,t)=>(o.f[t](e,r),r),[])),o.u=e=>e+\\".\\"+e+\\".cf75d036d67393467f48.js\\",o.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),o.r=e=>{\\"undefined\\"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:\\"Module\\"}),Object.defineProperty(e,\\"__esModule\\",{value:!0})},o.p=\\"\\",(()=>{var e={988:0};o.f.j=(r,t)=>{var n=o.o(e,r)?e[r]:void 0;if(0!==n)if(n)t.push(n[2]);else{var a=new Promise((o,t)=>{n=e[r]=[o,t]});t.push(n[2]=a);var i,s=o.p+o.u(r),u=document.createElement(\\"script\\");u.charset=\\"utf-8\\",u.timeout=120,o.nc&&u.setAttribute(\\"nonce\\",o.nc),u.src=s;var d=new Error;i=t=>{i=()=>{},u.onerror=u.onload=null,clearTimeout(p);var a=(()=>{if(o.o(e,r)&&(0!==(n=e[r])&&(e[r]=void 0),n))return n[1]})();if(a){var s=t&&(\\"load\\"===t.type?\\"missing\\":t.type),c=t&&t.target&&t.target.src;d.message=\\"Loading chunk \\"+r+\\" failed.\\\\n(\\"+s+\\": \\"+c+\\")\\",d.name=\\"ChunkLoadError\\",d.type=s,d.request=c,a(d)}};var p=setTimeout(()=>{i({type:\\"timeout\\",target:u})},12e4);u.onerror=u.onload=i,document.head.appendChild(u)}};var r=window.webpackJsonp=window.webpackJsonp||[],t=r.push.bind(r);r.push=function(r){for(var t,a,i=r[0],s=r[1],u=r[3],d=0,p=[];d<i.length;d++)a=i[d],o.o(e,a)&&e[a]&&p.push(e[a][0]),e[a]=0;for(t in s)o.o(s,t)&&(o.m[t]=s[t]);for(u&&u(o),n&&n(r);p.length;)p.shift()()};var n=t})(),o.e(598).then(o.bind(o,598)).then(()=>{console.log(\\"Good\\")})})();",
"importExport.1ef0713957688ee348c5.js": "(()=>{\\"use strict\\"})();",
"js.2e63108f1fb4b5be0554.js": "(()=>{var r={791:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(791)})();",
"mjs.d41879149cfce34517a1.js": "(()=>{var r={631:r=>{r.exports=function(){console.log(7)}}},o={};!function t(e){if(o[e])return o[e].exports;var n=o[e]={exports:{}};return r[e](n,n.exports,t),n.exports}(631)})();",
}
`;

Expand Down
Loading

0 comments on commit d3f0c81

Please sign in to comment.