karma-rollup-plugin
[DEPRECATED] Use https://github.com/jlmakes/karma-rollup-preprocessor instead
[DEPRECATED] Use https://github.com/jlmakes/karma-rollup-preprocessor
License: MIT License
[DEPRECATED] Use https://github.com/jlmakes/karma-rollup-preprocessor instead
My office still use node0.12. I'm trying to force upgrade but it's not so fast. Also until rollup itself supports 0.12 any plugins and adapters should follow the same. Usually our travis conf looks like this
# sudo is not required since jan 2015
language: node_js
node_js:
- "0.12"
- "4"
- "6"
env:
global:
- BUILD_TIMEOUT=10000
# node_js env knows what to do
# install: npm install
# script: npm run ci
Or how to use multiple config?
module.exports = (config) => {
config.set({
preprocessors: {
'src/vendor.js': ['rollup'], // 1
'test/**/*.spec.js': ['rollup'] // 2
},
rollupPreprocessor: [
{ ... }, // 1
{ ... } // 2
]
});
};
when I change source code(not test code), it still bundle old source code, any solution?
Rollup generates source maps. It's fine. But karma can't load them from string without sourcemap preprocessor. But better just add file.map
and get rid from extra plugin.
Pass debounce
, rollup
to regular dependencies
instead of devDependencies
.
@TrySound I have no time anymore to maintain this repo because I'm working on a huge project, and things are not completed yet. Should I transfer it to you? If not I think it will be deleted shortly.
If one adds "karma-rollup-plugin": "Kflash/karma-rollup-plugin"
to dependencies
or devDependencies
of package.json
and runs npm install
then node will fail with a "Cannot find plugin".
This is because package.json
has "main": "dist/rollup-plugin-karma.js"
, but that is not present when npm install
gets the package from Github.
There are a few options to resolve this e.g.
dist/
directory on master.package.json
can reference that tagged version)rollup.config.js
in files
of package.json
(so it can be at least compiled without having to explicitly fetch it)There may be other/better ways to resolve this, but I just thought I'd give a heads up since npm
supports installation from repository, and it's probably the easiest way to try out and debug the latest.
Cheers.
Since one of the last releases rollup introduced cache
option which accepts previously built bundle and contain transformed content and maps.
let cache = null;
rollup.rollup({
entry: '...',
plugins: [buble()],
cache
}).then(bundle => {
cache = bundle;
});
rollup.rollup({
entry: '...',
plugins: [buble()],
cache // contains buble transformations
}).then(bundle => {
cache = bundle;
});
rollup version: 0.45.2
config:
preprocessors: {
'__test__/index.js': ['rollup']
},
rollupPreprocessor: {
plugins: [
postcss({
plugins: [
cssnext()
],
extensions: ['.css']
}),
babel({
presets: ['es2015-rollup', 'stage-0'],
plugins: [
'transform-decorators-legacy',
'transform-runtime'
],
exclude: 'node_modules/**',
runtimeHelpers: true,
babelrc: false
}),
resolve(),
commonjs()
],
format: 'iife',
sourceMap: 'inline'
},
terminal console.log: bundle.generate(...) now returns a Promise instead of a { code, map } object
resolve: rollup issues
@TrySound You know the interal Rollup source code better then I do, so can you look into this?
Look at this source code to get an idea:
https://github.com/webpack/karma-webpack/blob/master/index.js
This is interesting:
https://github.com/webpack/karma-webpack/blob/master/index.js#L106-L115
When setting rollup to preprocess my tests, the autowatch is identifying the tests as not being in the files
list and the following message is being shown:
Changed file "/path/to/test.js" ignored. Does not match any file in the list.
However, when disabling the plugin it works as expected.
This is my config file:
const buble = require('rollup-plugin-bible');
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
files: [ 'tests/**/*.js' ],
rollupPreprocessor: {
plugins: [ buble() ],
format: 'es',
},
preprocessors: {
'tests/**/*.js': ['rollup']
},
reporters: ['progress'],
port: 9876,
colors: true,
logLevel: config.LOG_DEBUG,
autoWatch: true,
browsers: ['PhantomJS'],
singleRun: false,
concurrency: Infinity
})
}
Version 0.23, line 46 of dist/rollup-plugin-karma.js has this:
console.log(files);
Since I don't see this in the repo, I guess something wrong was published.
I noticed that in one of my projects karma tests started failing in a combination with Jasmine (jasmine.js missing). If I revert to 0.2.2
everything is fine. Here's my repo and karma configuration if it's helpful: angular2-rollup-starter. Btw, thanks for this plugin!
The debounce on line 45 is creating a new debounced' function for every dependency of every processed file. This exponentially increases the computational complexity.
The debounce'd function definition should be moved outside the createPreprocessor
function. e.g.
let triggerUpdateChanges = debounce(() => {
let now = new Date();
for (let idx = 0, lst = changedParents.values(); idx < lst.length; idx += 1) {
fs.utimes(lst[idx], now, now);
}
changedParents.clear();
}, WAIT)
Then line 45 would just be triggerUpdateChanges()
.
@TrySound I have to revert some of your source fixes because something weird happen. It doesn't work anymore. SyntaxError: Unexpected token ')'
Seems like Rollup isn't invoked?
Actually no time for this atm, but I have no choices rather then fix this :(
There is buble/register
hook. This will make tests a bit more consistent to source code.
// You don't need to specify exact path. `package.json` `main` field will be resolved perfectly.
const karmaRollupPlugin = require('../../');
@TrySound Should there be possible to debug the preprocessor? Maybe not possible because it will rely on Rollup and there is no build in debug feature.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.