@oinone/kunlun-compile 7.1.0 → 7.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.min.js CHANGED
@@ -1 +1 @@
1
- import e from"fs";import s from"path";import t from"@rollup/plugin-commonjs";import i from"@rollup/plugin-json";import r from"@rollup/plugin-node-resolve";import n from"@rollup/plugin-replace";import u from"@rollup/plugin-terser";import o from"@rollup/plugin-typescript";import p from"rollup-plugin-copy";import l from"rollup-plugin-scss";import c from"rollup-plugin-sourcemaps";import a from"rollup-plugin-typescript2";import d from"rollup-plugin-vue";function h(e,s,t,i){return new(t||(t=Promise))(function(r,n){function u(e){try{p(i.next(e))}catch(e){n(e)}}function o(e){try{p(i.throw(e))}catch(e){n(e)}}function p(e){var s;e.done?r(e.value):(s=e.value,s instanceof t?s:new t(function(e){e(s)})).then(u,o)}p((i=i.apply(e,s||[])).next())})}"function"==typeof SuppressedError&&SuppressedError;class m{static config(e){const s=new m;return s._debug=e,s}prefix(e,s="oinone-"){const t=e.replace("@","").replace("/","-"),i=t.substring(s.length),r=t.replace(/-(\w)/g,(e,s)=>s.toUpperCase());return this._libraryName=t,this._pathName=i,this._camelCaseName=r,this}get libraryName(){return this._libraryName}set libraryName(e){this._libraryName=e}setLibraryName(e){return this._libraryName=e,this}get pathName(){return this._pathName}set pathName(e){this._pathName=e}setPathName(e){return this._pathName=e,this}get camelCaseName(){return this._camelCaseName}set camelCaseName(e){this._camelCaseName=e}setCamelCaseName(e){return this._camelCaseName=e,this}get isDebug(){return!!this._debug}external(e){return Array.isArray(e)?this._external=[/node_modules/,...e]:this._external=[/node_modules/,e],this}singleModule(){return this._pluginBuilder=new g(this),this._pluginBuilder}multipleModule(){return this._pluginBuilder=new y(this),this._pluginBuilder}build(e,s){const{_libraryName:t,_external:i}=this;return{input:"index.ts",output:(null==e?void 0:e.outputOverride)||[Object.assign({file:`dist/${t}.esm.js`,format:"esm",sourcemap:!1},null==e?void 0:e.output)],onwarn(e){"THIS_IS_UNDEFINED"===e.code||/Circular/.test(e.message)||console.error(e.message)},preserveSymlinks:!1,makeAbsoluteExternalsRelative:"ifRelativeSource",external:i,plugins:s}}}class _{constructor(e){this.defaultTypescriptCompilerOptions={outDir:"dist",declaration:!0,declarationDir:"dist/types",moduleResolution:"Bundler",incremental:!1,sourceMap:!1},this._builder=e}get libraryName(){return this._builder.libraryName}get pathName(){return this._builder.pathName}get camelCaseName(){return this._builder.camelCaseName}replace(e=!0){return this.$$setPluginOptions(e=>this._replace=e,e,{"process.env.NODE_ENV":JSON.stringify("development"),preventAssignment:!0,__VUE_OPTIONS_API__:!0,__VUE_PROD_DEVTOOLS__:!1,__VUE_PROD_HYDRATION_MISMATCH_DETAILS__:!1})}scss(e=!0){const{libraryName:s}=this._builder;return this.$$setPluginOptions(e=>this._scss=e,e,{fileName:`${s}.scss`,output:"dist",sourceMap:!1,outputStyle:"compressed"})}vue(e=!0){return this.$$setPluginOptions(e=>this._vue=e,e,{})}nodeResolve(e=!0){return this.$$setPluginOptions(e=>this._nodeResolve=e,e,{})}commonjs(e=!0){return this.$$setPluginOptions(e=>this._commonjs=e,e,{})}typescript(e=!0){return this.$$setPluginOptions(e=>this._typescript=e,e,{})}typescript2(e=!0){return this.$$setPluginOptions(e=>this._typescript2=e,e,{})}json(e=!0){return this.$$setPluginOptions(e=>this._json=e,e,{})}terser(e=!0){return this.$$setPluginOptions(e=>this._terser=e,e,{})}sourcemaps(e=!0){return this.$$setPluginOptions(e=>this._sourcemaps=e,e,{})}copy(e=!0){return this.$$setPluginOptions(e=>this._copy=e,e,{})}copyTypeFiles(t,i){this._plugins||(this._plugins=[]);const r=p({hook:"writeBundle",targets:[{src:`dist/types/${t}`,dest:"dist/types"}]}),n=process.cwd(),u=[];return Array.isArray(i)?u.push(...i.map(e=>s.resolve(n,`dist/types/${e}`))):u.push(s.resolve(n,`dist/types/${i}`)),this._plugins.push({name:"copy-and-delete-type-files",hook:"writeBundle",writeBundle:()=>h(this,void 0,void 0,function*(){var s;yield null===(s=r.writeBundle)||void 0===s?void 0:s.call(r);for(const s of u)e.existsSync(s)&&e.statSync(s).isDirectory()&&e.rm(s,{recursive:!0,force:!0},()=>{})})}),this}plugins(e){return this._plugins||(this._plugins=[]),Array.isArray(e)?this._plugins.push(...e):this._plugins.push(e),this}$$setPluginOptions(e,s,t){return(e=e.bind(this))("boolean"==typeof s?s?Object.assign({},t):void 0:Object.assign(Object.assign({},t),s)),this}build(e){return this._builder.build(e,this.buildPlugins())}buildPlugins(){const{_replace:e,_scss:s,_vue:h,_nodeResolve:m,_commonjs:_,_typescript:g,_typescript2:y,_json:f,_copy:b,_terser:O,_sourcemaps:$,_plugins:N}=this,v=[];return e&&v.push(n(e)),h&&v.push(d(h)),m&&v.push(r(m)),_&&v.push(t(_)),s&&v.push(l(s)),y?v.push(a(y)):g&&v.push(o(g)),f&&v.push(i(f)),O&&v.push(u(O)),$&&v.push(c($)),b&&v.push(p(b)),N&&v.push(...N),v}}class g extends _{constructor(e){super(e)}typescript(e=!0){return this.$$setPluginOptions(e=>this._typescript=e,e,{compilerOptions:Object.assign({},this.defaultTypescriptCompilerOptions),include:["index.ts","src/**/*.ts"],exclude:["**/__tests__/**/*.ts"]})}typescript2(e=!0){const t=s.resolve(process.cwd(),"./");let i={};return this._builder.isDebug&&(i={clean:!0,abortOnError:!1}),this.$$setPluginOptions(e=>this._typescript2=e,e,Object.assign(Object.assign({cwd:t,useTsconfigDeclarationDir:!0},i),{tsconfigOverride:{compilerOptions:Object.assign({},this.defaultTypescriptCompilerOptions),include:["index.ts","src/**/*.ts"],exclude:["**/node_modules/**/*","**/__tests__/**/*"]},include:["index.ts","src/**/*.ts"],exclude:["**/node_modules/**/*","**/__tests__/**/*"]}))}}class y extends _{constructor(e){super(e)}typescript(e=!0){return this.$$setPluginOptions(e=>this._typescript=e,e,{tsconfig:"../../tsconfig.json",compilerOptions:Object.assign({},this.defaultTypescriptCompilerOptions),include:["index.ts","src/**/*.ts"],exclude:["node_modules","**/__tests__/**/*.ts"]})}typescript2(e=!0){const t=s.resolve(process.cwd(),"../../"),i=`packages/${this._builder.pathName}`;let r={};return this._builder.isDebug&&(r={clean:!0,abortOnError:!1}),this.$$setPluginOptions(e=>this._typescript2=e,e,Object.assign(Object.assign({cwd:t,useTsconfigDeclarationDir:!0},r),{tsconfigOverride:{compilerOptions:Object.assign(Object.assign({},this.defaultTypescriptCompilerOptions),{outDir:`${i}/dist`,declarationDir:`${i}/dist/types`}),include:[`${i}/index.ts`,`${i}/src/**/*.ts`],exclude:["**/node_modules/**/*","**/__tests__/**/*"]},include:["index.ts","src/**/*.ts"],exclude:["**/node_modules/**/*","**/__tests__/**/*"]}))}}const f=({pkg:e,prefix:s="oinone-kunlun-",includeExternal:t,excludeExternal:i,hasVue:r=!0,hasSCSS:n=!0,ugly:u=!0,keep_classnames:o=!0,extendPlugins:p,outputEntryFiles:l=!1,copyTypeFiles:c,debug:a})=>{const d=[];O(d,Object.keys(e.dependencies||{})),O(d,Object.keys(e.devDependencies||{}));const h=[...new Set([...d,...t||[]]).difference(new Set([...i||[]]))],_=m.config(a).prefix(e.name,s).external(h).multipleModule().replace().nodeResolve().commonjs().json().plugins(p);return r?_.vue().typescript2():_.typescript2(),n&&_.scss(),u&&_.terser({keep_classnames:o}),c&&_.copyTypeFiles(c.typesDir,c.deleteDir),l?_.build({outputOverride:{dir:"dist",entryFileNames:`${_.libraryName}.esm.js`,format:"esm",sourcemap:!1}}):_.build()};function b(e){return e.replace(/[\\^$.*+?|()[\]{}]/g,"\\$&")}function O(e,s){for(const t of s)e.push(t),e.push(new RegExp(`^${b(t)}`))}export{m as default,f as rollupConfig};
1
+ import e from"fs";import s from"path";import t from"@rollup/plugin-commonjs";import i from"@rollup/plugin-json";import r from"@rollup/plugin-node-resolve";import n from"@rollup/plugin-replace";import l from"@rollup/plugin-terser";import u from"@rollup/plugin-typescript";import o from"rollup-plugin-copy";import p from"rollup-plugin-scss";import c from"rollup-plugin-sourcemaps";import a from"rollup-plugin-typescript2";import d from"rollup-plugin-vue";function h(e,s,t,i){return new(t||(t=Promise))(function(r,n){function l(e){try{o(i.next(e))}catch(e){n(e)}}function u(e){try{o(i.throw(e))}catch(e){n(e)}}function o(e){var s;e.done?r(e.value):(s=e.value,s instanceof t?s:new t(function(e){e(s)})).then(l,u)}o((i=i.apply(e,s||[])).next())})}function m(e){return e.replace(/[\\^$.*+?|()[\]{}]/g,"\\$&")}function _(e,s){for(const t of s)e.push(t),e.push(new RegExp(`^${m(t)}`))}"function"==typeof SuppressedError&&SuppressedError;class g{static config(e){const s=new g;return s._debug=e,s}prefix(e,s="oinone-"){const t=e.replace("@","").replace("/","-"),i=t.substring(s.length),r=t.replace(/-(\w)/g,(e,s)=>s.toUpperCase());return this._libraryName=t,this._pathName=i,this._camelCaseName=r,this}get libraryName(){return this._libraryName}set libraryName(e){this._libraryName=e}setLibraryName(e){return this._libraryName=e,this}get pathName(){return this._pathName}set pathName(e){this._pathName=e}setPathName(e){return this._pathName=e,this}get camelCaseName(){return this._camelCaseName}set camelCaseName(e){this._camelCaseName=e}setCamelCaseName(e){return this._camelCaseName=e,this}get isDebug(){return!!this._debug}external(e){return Array.isArray(e)?this._external=[/node_modules/,...e]:this._external=[/node_modules/,e],this}externalPkg(e,s){const t=[];_(t,Object.keys(e.dependencies||{})),_(t,Object.keys(e.devDependencies||{}));const i=[...new Set([...t,...(null==s?void 0:s.includeExternal)||[]]).difference(new Set([...(null==s?void 0:s.excludeExternal)||[]]))];return this.external(i),this}singleModule(){return this._pluginBuilder=new f(this),this._pluginBuilder}multipleModule(){return this._pluginBuilder=new b(this),this._pluginBuilder}build(e,s){const{_libraryName:t,_external:i}=this;return{input:"index.ts",output:(null==e?void 0:e.outputOverride)||[Object.assign({file:`dist/${t}.esm.js`,format:"esm",sourcemap:!1},null==e?void 0:e.output)],onwarn(e){"THIS_IS_UNDEFINED"===e.code||/Circular/.test(e.message)||console.error(e.message)},preserveSymlinks:!1,makeAbsoluteExternalsRelative:"ifRelativeSource",external:i,plugins:s}}}class y{constructor(e){this.defaultTypescriptCompilerOptions={outDir:"dist",declaration:!0,declarationDir:"dist/types",moduleResolution:"Bundler",incremental:!1,sourceMap:!1},this._builder=e}get libraryName(){return this._builder.libraryName}get pathName(){return this._builder.pathName}get camelCaseName(){return this._builder.camelCaseName}replace(e=!0){return this.$$setPluginOptions(e=>this._replace=e,e,{"process.env.NODE_ENV":JSON.stringify("development"),preventAssignment:!0,__VUE_OPTIONS_API__:!0,__VUE_PROD_DEVTOOLS__:!1,__VUE_PROD_HYDRATION_MISMATCH_DETAILS__:!1})}scss(e=!0){const{libraryName:s}=this._builder;return this.$$setPluginOptions(e=>this._scss=e,e,{fileName:`${s}.scss`,output:"dist",sourceMap:!1,outputStyle:"compressed"})}vue(e=!0){return this.$$setPluginOptions(e=>this._vue=e,e,{})}nodeResolve(e=!0){return this.$$setPluginOptions(e=>this._nodeResolve=e,e,{})}commonjs(e=!0){return this.$$setPluginOptions(e=>this._commonjs=e,e,{})}typescript(e=!0){return this.$$setPluginOptions(e=>this._typescript=e,e,{})}typescript2(e=!0){return this.$$setPluginOptions(e=>this._typescript2=e,e,{})}json(e=!0){return this.$$setPluginOptions(e=>this._json=e,e,{})}terser(e=!0){return this.$$setPluginOptions(e=>this._terser=e,e,{})}sourcemaps(e=!0){return this.$$setPluginOptions(e=>this._sourcemaps=e,e,{})}copy(e=!0){return this.$$setPluginOptions(e=>this._copy=e,e,{})}copyTypeFiles(t,i){this._plugins||(this._plugins=[]);const r=o({hook:"writeBundle",targets:[{src:`dist/types/${t}`,dest:"dist/types"}]}),n=process.cwd(),l=[];return Array.isArray(i)?l.push(...i.map(e=>s.resolve(n,`dist/types/${e}`))):l.push(s.resolve(n,`dist/types/${i}`)),this._plugins.push({name:"copy-and-delete-type-files",hook:"writeBundle",writeBundle:()=>h(this,void 0,void 0,function*(){var s;yield null===(s=r.writeBundle)||void 0===s?void 0:s.call(r);for(const s of l)e.existsSync(s)&&e.statSync(s).isDirectory()&&e.rm(s,{recursive:!0,force:!0},()=>{})})}),this}plugins(e){return this._plugins||(this._plugins=[]),Array.isArray(e)?this._plugins.push(...e):this._plugins.push(e),this}$$setPluginOptions(e,s,t){return(e=e.bind(this))("boolean"==typeof s?s?Object.assign({},t):void 0:Object.assign(Object.assign({},t),s)),this}build(e){return this._builder.build(e,this.buildPlugins())}buildPlugins(){const{_replace:e,_scss:s,_vue:h,_nodeResolve:m,_commonjs:_,_typescript:g,_typescript2:y,_json:f,_copy:b,_terser:O,_sourcemaps:$,_plugins:x}=this,N=[];return e&&N.push(n(e)),h&&N.push(d(h)),m&&N.push(r(m)),_&&N.push(t(_)),s&&N.push(p(s)),y?N.push(a(y)):g&&N.push(u(g)),f&&N.push(i(f)),O&&N.push(l(O)),$&&N.push(c($)),b&&N.push(o(b)),x&&N.push(...x),N}}class f extends y{constructor(e){super(e)}typescript(e=!0){return this.$$setPluginOptions(e=>this._typescript=e,e,{compilerOptions:Object.assign({},this.defaultTypescriptCompilerOptions),include:["index.ts","src/**/*.ts"],exclude:["**/__tests__/**/*.ts"]})}typescript2(e=!0){const t=s.resolve(process.cwd(),"./");let i={};return this._builder.isDebug&&(i={clean:!0,abortOnError:!1}),this.$$setPluginOptions(e=>this._typescript2=e,e,Object.assign(Object.assign({cwd:t,useTsconfigDeclarationDir:!0},i),{tsconfigOverride:{compilerOptions:Object.assign({},this.defaultTypescriptCompilerOptions),include:["index.ts","src/**/*.ts"],exclude:["**/node_modules/**/*","**/__tests__/**/*"]},include:["index.ts","src/**/*.ts"],exclude:["**/node_modules/**/*","**/__tests__/**/*"]}))}}class b extends y{constructor(e){super(e)}typescript(e=!0){return this.$$setPluginOptions(e=>this._typescript=e,e,{tsconfig:"../../tsconfig.json",compilerOptions:Object.assign({},this.defaultTypescriptCompilerOptions),include:["index.ts","src/**/*.ts"],exclude:["node_modules","**/__tests__/**/*.ts"]})}typescript2(e=!0){const t=s.resolve(process.cwd(),"../../"),i=`packages/${this._builder.pathName}`;let r={};return this._builder.isDebug&&(r={clean:!0,abortOnError:!1}),this.$$setPluginOptions(e=>this._typescript2=e,e,Object.assign(Object.assign({cwd:t,useTsconfigDeclarationDir:!0},r),{tsconfigOverride:{compilerOptions:Object.assign(Object.assign({},this.defaultTypescriptCompilerOptions),{outDir:`${i}/dist`,declarationDir:`${i}/dist/types`}),include:[`${i}/index.ts`,`${i}/src/**/*.ts`],exclude:["**/node_modules/**/*","**/__tests__/**/*"]},include:["index.ts","src/**/*.ts"],exclude:["**/node_modules/**/*","**/__tests__/**/*"]}))}}const O=({pkg:e,prefix:s="oinone-kunlun-",includeExternal:t,excludeExternal:i,hasVue:r=!0,hasSCSS:n=!0,ugly:l=!0,keep_classnames:u=!0,extendPlugins:o,outputEntryFiles:p=!1,copyTypeFiles:c,debug:a})=>{const d=g.config(a).prefix(e.name,s).externalPkg(e,{includeExternal:t,excludeExternal:i}).multipleModule().replace().nodeResolve().commonjs().json().plugins(o);return r?d.vue().typescript2():d.typescript2(),n&&d.scss(),l&&d.terser({keep_classnames:u}),c&&d.copyTypeFiles(c.typesDir,c.deleteDir),p?d.build({outputOverride:{dir:"dist",entryFileNames:`${d.libraryName}.esm.js`,format:"esm",sourcemap:!1}}):d.build()};export{g as default,O as rollupConfig};
@@ -37,6 +37,10 @@ export declare class CompileConfigBuilder {
37
37
  setCamelCaseName(val: string | undefined): CompileConfigBuilder;
38
38
  get isDebug(): boolean;
39
39
  external(val: RollupExternalTypes): CompileConfigBuilder;
40
+ externalPkg(pkg: any, options?: {
41
+ includeExternal?: (string | RegExp)[];
42
+ excludeExternal?: (string | RegExp)[];
43
+ }): CompileConfigBuilder;
40
44
  singleModule(): RollupSingleModulePluginBuilder;
41
45
  multipleModule(): RollupMultipleModulePluginBuilder;
42
46
  build(options?: RollupBuildOptions, plugins?: RollupPlugin[]): RollupOptions;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oinone/kunlun-compile",
3
- "version": "7.1.0",
3
+ "version": "7.2.1",
4
4
  "type": "module",
5
5
  "main": "dist/index.min.js",
6
6
  "types": "dist/types/index.d.ts",