Skip to content

Commit

Permalink
migrate to esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
gutenfries committed Oct 21, 2023
1 parent b72d551 commit 9e7032d
Show file tree
Hide file tree
Showing 13 changed files with 9,222 additions and 5,661 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 20.x]
node-version: [16.x, 18.x, 20.x]

steps:
- uses: actions/checkout@v3
Expand All @@ -22,11 +22,8 @@ jobs:
with:
node-version: ${{ matrix.node-version }}

- name: Set up yarn
run: npm install -g yarn

- name: Install dependencies
run: yarn install --frozen-lockfile
run: npm install

- name: Test
run: yarn test
run: npm run test
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
### Copyright (c) Mark Gutenberger under the MIT ##
###################################################


./src/**/*.d.ts
./src/**/*.js

####################################################
################### General Rules ##################
Expand Down
49 changes: 49 additions & 0 deletions bundle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const estrella = require('estrella');

const base = {
entry: 'src/index.ts',
bundle: true,
sourcemap: true,
};

estrella.build({
...base,
outfile: 'dist/browser/bundle.js',
format: 'iife',
tsconfig: 'tsconfig.browser.json',
onEnd(config) {
const dtsFilesOutdir = estrella.dirname(config.outfile);
generateTypeDefs(estrella.tsconfig(config), config.entry, dtsFilesOutdir);
},
});

estrella.build({
...base,
outfile: 'dist/node/index.js',
format: 'cjs',
tsconfig: 'tsconfig.node.json',
onEnd(config) {
const dtsFilesOutdir = estrella.dirname(config.outfile);
generateTypeDefs(estrella.tsconfig(config), config.entry, dtsFilesOutdir);
},
});

function generateTypeDefs(tsconfig, entryfiles, outdir) {
const filenames = Array.from(
new Set((Array.isArray(entryfiles) ? entryfiles : [entryfiles]).concat(estrella.tsconfig.include || []))
).filter((v) => v);
estrella.log.info('Generating type declaration files for', filenames.join(', '));
const compilerOptions = {
...estrella.tsconfig.compilerOptions,
moduleResolution: undefined,
declaration: true,
outDir: outdir,
};
const program = estrella.ts.ts.createProgram(filenames, compilerOptions);
const targetSourceFile = undefined;
const writeFile = undefined;
const cancellationToken = undefined;
const emitOnlyDtsFiles = true;
program.emit(targetSourceFile, writeFile, cancellationToken, emitOnlyDtsFiles);
estrella.log.info('Wrote', estrella.glob(outdir + '/*.d.ts').join(', '));
}
37 changes: 0 additions & 37 deletions gulpfile.js

This file was deleted.

1 change: 0 additions & 1 deletion index.ts

This file was deleted.

Loading

0 comments on commit 9e7032d

Please sign in to comment.