Skip to content

Commit

Permalink
improve karma
Browse files Browse the repository at this point in the history
  • Loading branch information
sasaplus1 committed Mar 8, 2021
1 parent c2cf15d commit 38be369
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 37 deletions.
30 changes: 13 additions & 17 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ const path = require('path');

const commonjs = require('@rollup/plugin-commonjs');
const { default: nodeResolve } = require('@rollup/plugin-node-resolve');
const ts = require('@wessberg/rollup-plugin-ts');
// NOTE: fail build when use @wessberg/rollup-plugin-ts
const typescript = require('@rollup/plugin-typescript');

const meta = require('./package.json');

Expand Down Expand Up @@ -48,26 +49,21 @@ module.exports = function (config) {
},
reporters: ['dots'],
rollupPreprocessor: {
plugins: [
nodeResolve(),
commonjs(),
ts({
tsconfig(resolvedConfig) {
return {
...resolvedConfig,
inlineSourceMap: true,
module: 'ESNext',
sourceMap: false,
target: 'ES5'
};
}
})
],
output: {
format: 'iife',
name: meta.name,
sourcemap: 'inline'
}
},
plugins: [
nodeResolve(),
commonjs(),
typescript({
esModuleInterop: true,
module: 'ESNext',
target: 'ES5',
tsconfig: false
})
]
}
});
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"devDependencies": {
"@rollup/plugin-commonjs": "^17.1.0",
"@rollup/plugin-node-resolve": "^11.2.0",
"@rollup/plugin-typescript": "^8.2.0",
"@types/mocha": "^8.0.1",
"@types/node": "^13.13.2",
"@types/type-detect": "^4.0.1",
Expand All @@ -31,7 +32,7 @@
"karma-espower-preprocessor": "^1.2.0",
"karma-mocha": "^2.0.1",
"karma-power-assert": "^1.0.0",
"karma-rollup-preprocessor": "^7.0.5",
"karma-rollup-preprocessor": "^7.0.6",
"lint-staged": "^10.2.11",
"mocha": "^8.1.1",
"npm-run-all": "^4.1.5",
Expand Down
18 changes: 3 additions & 15 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@ if (process.env.build === 'esm') {
tsconfig(resolvedConfig) {
return {
...resolvedConfig,
declaration: false,
module: 'ESNext',
outDir: './dist/esm'
declaration: false
};
}
})
Expand Down Expand Up @@ -74,8 +72,6 @@ if (process.env.build === 'umd') {
return {
...resolvedConfig,
declaration: false,
outDir: './dist/umd',
sourceMap: false,
target: 'ES5'
};
}
Expand All @@ -99,8 +95,6 @@ if (process.env.build === 'umd') {
return {
...resolvedConfig,
declaration: false,
outDir: './dist/umd',
sourceMap: false,
target: 'ES5'
};
}
Expand All @@ -127,10 +121,7 @@ if (process.env.build === 'umd') {
tsconfig(resolvedConfig) {
return {
...resolvedConfig,
declaration: false,
module: 'ESNext',
outDir: './dist/umd',
sourceMap: false
declaration: false
};
}
})
Expand All @@ -152,10 +143,7 @@ if (process.env.build === 'umd') {
tsconfig(resolvedConfig) {
return {
...resolvedConfig,
declaration: false,
module: 'ESNext',
outDir: './dist/umd',
sourceMap: false
declaration: false
};
}
}),
Expand Down
16 changes: 12 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -960,6 +960,14 @@
is-module "^1.0.0"
resolve "^1.19.0"

"@rollup/plugin-typescript@^8.2.0":
version "8.2.0"
resolved "https://registry.yarnpkg.com/@rollup/plugin-typescript/-/plugin-typescript-8.2.0.tgz#3e2059cbcae916785d8d7bf07816210c829f817c"
integrity sha512-5DyVsb7L+ehLfNPu/nat8Gq3uJGzku4bMFPt90XahtgiSBf7z9YKPLqFUJKMT41W/mJ98SVGDPOhzikGrr/Lhg==
dependencies:
"@rollup/pluginutils" "^3.1.0"
resolve "^1.17.0"

"@rollup/pluginutils@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b"
Expand Down Expand Up @@ -3085,10 +3093,10 @@ karma-power-assert@^1.0.0:
resolved "https://registry.yarnpkg.com/karma-power-assert/-/karma-power-assert-1.0.0.tgz#c7682b32c15cc163c3f24966f9e2f9cf30e47872"
integrity sha1-x2grMsFcwWPD8klm+eL5zzDkeHI=

karma-rollup-preprocessor@^7.0.5:
version "7.0.5"
resolved "https://registry.yarnpkg.com/karma-rollup-preprocessor/-/karma-rollup-preprocessor-7.0.5.tgz#d2cd9c8e654bc1451c31518bc18e6b022237deff"
integrity sha512-VhZI81l8LZBvBrSf4xaojsbur7bcycsSlxXkYaTOjV6DQwx1gtAM0CQVdue7LuIbXB1AohYIg0S5at+dqDtMxQ==
karma-rollup-preprocessor@^7.0.6:
version "7.0.6"
resolved "https://registry.yarnpkg.com/karma-rollup-preprocessor/-/karma-rollup-preprocessor-7.0.6.tgz#7abb3b037ed5c8351bab17d8f0c6aa3912ed2b5a"
integrity sha512-Qghr/oNnmNKB4Ry5n81QX+tB6+vSy0kjn+rwzH1dp80ZVf9WiA19NQqVFZLc0f76tBoE7is2Qef8dqbVNjVtjw==
dependencies:
chokidar "^3.3.1"
debounce "^1.2.0"
Expand Down

0 comments on commit 38be369

Please sign in to comment.