Comments (13)
@jlmakes - do you think you could integrate this into the package?
from karma-rollup-preprocessor.
Thanks for the reproduction. I removed TypeScript from the project and everything works normally. That narrows things.
from karma-rollup-preprocessor.
Can confirm that, using babel watch works correctly. After digging a while I found that @rollup/plugin-typescript
uses an internal watcher, maybe this is causing some errors?
from karma-rollup-preprocessor.
karma-rollup-preprocessor
has its own watcher that manually re-runs Karma, but presently I don't deeply understand how Karma goes about generating/serving temporary files. Although, if it works without the TS plugin, it makes me think the problem lies in how @rollup/plugin-typescript
names its output files, perhaps related to the file watcher or a caching strategy. 🤔
There is a bit of file name shuffling in order to get source maps working, and to account for file extension changes. If there is a fix that can be implemented in preprocessor land (as opposed to in the plug-in itself) it likely has to do with that.
There are other users that have been using TypeScript though: https://github.com/jlmakes/karma-rollup-preprocessor/blob/master/CHANGELOG.md#fixed-6 but it looks like it was done using Babel.
from karma-rollup-preprocessor.
I can confirm that there is an issue with watching files and official TS plugin @rollup/plugin-typescript
. Switching to @rollup/plugin-babel
helped in my case:
My plugins inside rollupPreprocessor
in karma.conf.js
:
plugins: [
progress(),
babel( {
babelHelpers: 'bundled',
presets: [
'@babel/preset-env',
'@babel/preset-typescript',
'@babel/preset-react'
],
extensions: [ '.ts', '.tsx', '.js' ],
exclude: 'node_modules/**'
} ),
nodeResolve( {
preferBuiltins: false,
extensions: [ '.ts', '.tsx', '.js' ]
} ),
commonJs(),
polyfillNode()
],
With babel plugin it's just transpilation (no type checking) but I don't think it's a big deal in case of generating test bundle.
from karma-rollup-preprocessor.
So I have been spending a few days looking at this and it looks like it's partially related to @rollup/typescript
and partially down to the structure of this preprocessor.
After diving through the @rollup/typescript
code, it looks like the plugins "emitted files" cache is maintained at the plugin instance level, not per Rollup run. Since this preprocessor calls rollup.rollup()
multiple times with the same config, the instance of the plugin is maintained as does the cache, hence every time the file changes the previously compiled one is emitted again.
I assume something different happens when running rollup.watch()
as my main build (using an identical rollup config) works fine.
Is there a way to modify the preprocessor to use rollup.watch()
and its internal watcher, while still saying to Karma "hey stuff has changed, you should do what you need to" in the same way as refreshFiles
does?
I'm going to keep messing around with this on my end to see if I can make it work, but any pointers would be great.
from karma-rollup-preprocessor.
Follow up, after doing an ugly version of the processor that uses rollup.watch()
rather than rollup.rollup()
I am getting the output I expect, where the files are rebuilt and refreshing the debug page gives the updated files/test results.
It's very specific to my setup right now but it's doing what I need so I will clean it up and if people need it I can post.
from karma-rollup-preprocessor.
@xenobytezero I'd be curious to see your changes. If you have the time, please submit a PR.
from karma-rollup-preprocessor.
The changes are tied up in code it's a little tricky to open source right now, will see what I can do.
from karma-rollup-preprocessor.
@jlmakes I made it work.
I can't find the logic in the tests in order to write tests for it.
How do the tests work? All I see is a bunch of modules that import each other.
Please see this change: #74
from karma-rollup-preprocessor.
Just spend an hour solving this. My mistake for not looking further after noticing that my version matched your package.json at master.
Are you going to release soon?
from karma-rollup-preprocessor.
Thanks for your patience, the fix landed in 7.0.8
@mattalexx @YonatanKra
from karma-rollup-preprocessor.
Thanks @jlmakes
cc @Gusted
from karma-rollup-preprocessor.
Related Issues (20)
- Rollup has moved output options within the config
- sourcemaps not working HOT 4
- Add support of array configs HOT 4
- Source Maps not Working HOT 1
- Watching doesn't start when debugging HOT 4
- Not compatible with the latest version of Rollup (v1.0.0) HOT 2
- TypeError: Cannot read property 'forEach' of undefined HOT 4
- dynamic imports give a 404 HOT 4
- dependencies are duplicated for each test file HOT 19
- Issues using babel-typescript and @types packages HOT 3
- Watching fails to process files HOT 6
- Missing options in examples HOT 2
- Warnings when used with Rollup >= 1.27.0
- There are hints when using plug-ins that introduce files HOT 1
- @rollup/plugin-multi-entry broken by #54 HOT 6
- Watch not working on windows HOT 9
- #69 breaks configs with output.file HOT 1
- Watch mode overwrites the test file HOT 9
- New version containing fix for watch mode HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from karma-rollup-preprocessor.