Skip to content

Commit

Permalink
Esbuild & tsc & tsc-alias workgin with absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
arhtudormorar committed May 11, 2024
1 parent 1f33166 commit 6aa4d09
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 43 deletions.
75 changes: 36 additions & 39 deletions esbuild.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,49 +31,46 @@ function esbuildWrapper(
].join(',');

return function executeBuildCommand() {
glob(filesToInclude, function (err, allFiles) {
if (err) {
console.log('error reading files', err);
}
const allFiles = glob.sync(filesToInclude);

const files = allFiles.filter((file) => {
const hasTestFiles =
file.includes('/tests/') || file.includes('/stories/');
return !hasTestFiles;
});

esbuild
.build({
entryPoints: files,
splitting,
format,
outdir: `${options.outDir}${destination}`,
treeShaking: true,
minify: true,
bundle: true,
sourcemap: true,
chunkNames: '__chunks__/[name]-[hash]',
target: ['esnext'],
outExtension: { '.js': '.mjs' },
tsconfig,
platform: 'node',
define: {
global: 'global',
process: 'process',
Buffer: 'Buffer',
'process.env.NODE_ENV': `"production"`
}
})
.then(() => {
console.log(
'\x1b[36m%s\x1b[0m',
`[${new Date().toLocaleTimeString()}] sdk-dapp build succeeded for ${format} types`
);
})
.catch(() => process.exit(1));
const files = allFiles.filter((file) => {
const hasTestFiles =
file.includes('/tests/') || file.includes('/stories/');
return !hasTestFiles;
});

esbuild
.build({
entryPoints: files,
splitting,
format,
outdir: `${options.outDir}${destination}`,
treeShaking: true,
minify: true,
bundle: true,
sourcemap: true,
chunkNames: '__chunks__/[name]-[hash]',
target: ['es2021'],
outExtension: { '.js': '.mjs' },
tsconfig,
platform: 'node',
define: {
global: 'global',
process: 'process',
Buffer: 'Buffer',
'process.env.NODE_ENV': `"production"`
}
})
.then(() => {
console.log(
'\x1b[36m%s\x1b[0m',
`[${new Date().toLocaleTimeString()}] sdk-dapp build succeeded for ${format} types`
);
})
.catch(() => process.exit(1));
};
}

esbuildWrapper('esm')();
// cjs will be performed by tsc
// esbuildWrapper('cjs')();
10 changes: 6 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "@multiversx/sdk-dapp-core",
"version": "0.0.0-alpha.1",
"main": "out/cjs/index.js",
"module": "out/index.js",
"main": "out/index.js",
"module": "out/index.mjs",
"types": "out/index.d.ts",
"description": "A library to hold core logic for building TypeScript dApps on the MultiversX blockchain",
"author": "MultiversX",
Expand All @@ -25,21 +25,22 @@
"build-esbuild": "rimraf out && node esbuild.js",
"build": "rimraf out && node esbuild.js && yarn build:esm-types && yarn build:cjs",
"test": "jest",
"compile-next": "tsc --p tsconfig.next.json"
"compile-next": "rimraf out && tsc --p tsconfig.next.json && tsc-alias --project tsconfig.next.json"
},
"publishConfig": {
"access": "public"
},
"dependencies": {
"@multiversx/sdk-dapp-utils": "^0.0.1",
"@multiversx/sdk-web-wallet-cross-window-provider": "0.1.3",
"zustand": "^4.4.7"
},
"peerDependencies": {
"@multiversx/sdk-dapp-utils": "^0.0.1",
"@multiversx/sdk-core": ">= 12.18.0",
"axios": ">=1.6.5"
},
"devDependencies": {
"@multiversx/sdk-dapp-utils": "^0.0.1",
"@multiversx/sdk-core": ">= 12.18.0",
"@swc/core": "^1.4.17",
"@swc/jest": "^0.2.36",
Expand All @@ -56,6 +57,7 @@
"eslint-plugin-node": "11.1.0",
"eslint-plugin-prettier": "5.1.3",
"eslint-plugin-promise": "6.1.1",
"glob": "^10.3.14",
"immer": "^10.1.1",
"jest": "29.7.0",
"jest-environment-jsdom": "29.7.0",
Expand Down

0 comments on commit 6aa4d09

Please sign in to comment.