mirror of
https://github.com/danielsogl/awesome-cordova-plugins.git
synced 2026-05-02 00:07:23 +08:00
feat: migrate from Webpack to esbuild for optimized builds
- Updated build process to use esbuild, enhancing performance and reducing bundle size. - Introduced custom esbuild plugins to replicate Webpack functionality, including removal of duplicate tslib helpers. - Replaced the previous build script for ES5 with a new optimized version using esbuild. - Added support for TypeScript in esbuild configuration, ensuring compatibility with existing code. - Removed Webpack-related dependencies and configurations from package.json and renovate.json. This transition aims to streamline the build process and improve overall efficiency.
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
// Custom esbuild plugins to replace webpack functionality
|
||||
|
||||
/**
|
||||
* Plugin to remove duplicate tslib helpers that TypeScript might emit
|
||||
* Works with both .js and .ts files for comprehensive coverage
|
||||
*/
|
||||
const removeTslibHelpersPlugin = {
|
||||
name: 'remove-tslib-helpers',
|
||||
setup(build) {
|
||||
// Handle both JavaScript and TypeScript files
|
||||
build.onLoad({ filter: /\.(js|ts)$/ }, async (args) => {
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const contents = await fs.promises.readFile(args.path, 'utf8');
|
||||
|
||||
// Remove the __extends method that is added automatically by typescript
|
||||
const transformedContents = contents.replace(
|
||||
/var\s__extends\s=\s\(this\s&&[\sa-z\._\(\)\|{}=:\[\]&,;?]+}\)\(\);/i,
|
||||
''
|
||||
);
|
||||
|
||||
// Determine the correct loader based on file extension
|
||||
const ext = path.extname(args.path);
|
||||
const loader = ext === '.ts' ? 'ts' : 'js';
|
||||
|
||||
return {
|
||||
contents: transformedContents,
|
||||
loader: loader,
|
||||
};
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
removeTslibHelpersPlugin,
|
||||
};
|
||||
Reference in New Issue
Block a user