tsdx: zero 配置的打包工具

又一个零配置的打包工具
更新于: 2023-04-25 14:27:35

TSDX还在维护吗?

看到了这个精典问题,所以,暂时不打算继续研究这个项目了。

源码

// ./src/index.ts
export const sum = (a: number, b: number) => {
  if (process.env.NODE_ENV !== 'production') {
    console.log('Helpful dev-only error message');
  }
  return a + b;
};

打包后

// Entry File
// ./dist/index.js
'use strict';
// This determines which build to use based on the `NODE_ENV` of your end user.
if (process.env.NODE_ENV === 'production') {
  module.exports = require('./mylib.cjs.production.js');
} else {
  module.exports = require('./mylib.cjs.development.js');
}

// CommonJS Development Build
// ./dist/mylib.cjs.development.js
'use strict';
const sum = (a, b) => {
  {
    console.log('Helpful dev-only error message');
  }
  return a + b;
};
exports.sum = sum;

//# sourceMappingURL=mylib.cjs.development.js.map
// CommonJS Production Build
// ./dist/mylib.cjs.production.js
'use strict';
exports.sum = (s, t) => s + t;
//# sourceMappingURL=test-react-tsdx.cjs.production.js.map

参考