Skip to content

Commit

Permalink
Test - esbuild
Browse files Browse the repository at this point in the history
  • Loading branch information
sidharthv96 committed Sep 2, 2022
1 parent 04f1863 commit 99923fc
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
8 changes: 4 additions & 4 deletions .esbuild/util.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const buildOptions = (override = {}) => {
bundle: true,
minify: true,
keepNames: true,
banner: { js: '"use strict";' },
globalName: 'mermaid',
platform: 'browser',
tsconfig: 'tsconfig.json',
Expand Down Expand Up @@ -45,18 +46,17 @@ exports.umdBuild = (override = { minify: true }) => {
});
};

const { Generator } = require('jison');
let fs = require('fs');
const jisonPlugin = {
name: 'jison',
setup(build) {
const { Generator } = require('jison');
let fs = require('fs');

build.onLoad({ filter: /\.jison$/ }, async (args) => {
// Load the file from the file system
let source = await fs.promises.readFile(args.path, 'utf8');

try {
let contents = new Generator(source, {}).generate();
let contents = new Generator(source, { 'token-stack': true }).generate();
return { contents, warnings: [] };
} catch (e) {
return { errors: [] };
Expand Down
4 changes: 2 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const path = require('path');

/** @type {import('ts-jest/dist/types').InitialOptionsTsJest} */
module.exports = {
testEnvironment: 'jsdom',
preset: 'ts-jest',
transform: {
'^.+\\.jsx?$': ['babel-jest', { rootMode: 'upward' }],
'^.+\\.tsx?$': ['jest-esbuild', { banner: '"use strict";' }],
'^.+\\.jsx?$': ['jest-esbuild', { banner: '"use strict";' }],
'^.+\\.jison$': [
path.resolve(__dirname, './src/jison/transformer.js'),
{ 'token-stack': true },
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@
"@types/dompurify": "^2.3.3",
"@types/jest": "^28.1.7",
"@types/stylis": "^4.0.2",
"babel-jest": "^29.0.1",
"babel-loader": "^8.2.2",
"concurrently": "^7.0.0",
"coveralls": "^3.0.2",
"css-to-string-loader": "^0.1.3",
Expand All @@ -108,6 +106,7 @@
"identity-obj-proxy": "^3.0.0",
"jest": "^28.0.3",
"jest-environment-jsdom": "^29.0.1",
"jest-esbuild": "^0.2.9",
"jison": "^0.4.18",
"js-base64": "3.7.2",
"lint-staged": "^13.0.0",
Expand Down
10 changes: 9 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5711,7 +5711,7 @@ esbuild-windows-arm64@0.15.6:
resolved "https://registry.yarnpkg.com/esbuild-windows-arm64/-/esbuild-windows-arm64-0.15.6.tgz#e18a778d354fc2ca2306688f3fedad8a3e57819e"
integrity sha512-DB3G2x9OvFEa00jV+OkDBYpufq5x/K7a6VW6E2iM896DG4ZnAvJKQksOsCPiM1DUaa+DrijXAQ/ZOcKAqf/3Hg==

esbuild@^0.14.39:
esbuild@^0.14.39, esbuild@^0.14.48:
version "0.14.54"
resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.14.54.tgz#8b44dcf2b0f1a66fc22459943dccf477535e9aa2"
integrity sha512-Cy9llcy8DvET5uznocPyqL3BFRrFXSVqbgpMJ9Wz8oVjZlh/zUSNbPRbov0VX7VxN2JH1Oa0uNxZ7eLRb62pJA==
Expand Down Expand Up @@ -7860,6 +7860,14 @@ jest-environment-node@^28.1.3:
jest-mock "^28.1.3"
jest-util "^28.1.3"

jest-esbuild@^0.2.9:
version "0.2.9"
resolved "https://registry.yarnpkg.com/jest-esbuild/-/jest-esbuild-0.2.9.tgz#c4c103e510400ad8a080753fd990dfe5a2a76025"
integrity sha512-GfcQgHf8XPwUydEurYTRdrhrDblVFXtgOsKmE/7KADxbsC0c5xpxQBarak4X7K0wl5XXfTmw7Qtat2V0/ssreg==
dependencies:
debug "^4.3.4"
esbuild "^0.14.48"

jest-get-type@^28.0.2:
version "28.0.2"
resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-28.0.2.tgz#34622e628e4fdcd793d46db8a242227901fcf203"
Expand Down

0 comments on commit 99923fc

Please sign in to comment.