Skip to content

Commit

Permalink
Update webpack to use babel loader with support for TS. (#2119)
Browse files Browse the repository at this point in the history
* Upgrade to webpack 4, babel 7

* Use straight git link for webworkify dep

* Use simpler git url

* Re-add globalObject workaround

* Bump karma dep versions

* Dont preprocess non-test files

* Use @babel/register over ts-node

* Update demo `const` usage.

* Use webpack debug config in Karma configuration rather than duplication.
  • Loading branch information
itsjamie authored and johnBartos committed Feb 7, 2019
1 parent 2bd34b8 commit 0bbb9b8
Show file tree
Hide file tree
Showing 8 changed files with 16,891 additions and 11,927 deletions.
2 changes: 1 addition & 1 deletion demo/main.js
Expand Up @@ -1152,7 +1152,7 @@ function onConfigPersistenceChanged(event) {

function getEditorValue(options) {
options = $.extend({ parse: false }, options || {});
const value = configEditor.session.getValue();
let value = configEditor.session.getValue();

if (options.parse) {
try {
Expand Down
64 changes: 25 additions & 39 deletions karma.conf.js
@@ -1,9 +1,30 @@
// Karma configuration
// Generated on Tue Jul 18 2017 12:17:16 GMT-0700 (PDT)

const pkgJson = require('./package.json');
const webpack = require('webpack');
const path = require('path');
const merge = require('webpack-merge');
const webpackConfig = require('./webpack.config')({ debug: true })[0];
delete webpackConfig.entry;
delete webpackConfig.output;
const mergeConfig = merge(webpackConfig, {
devtool: 'inline-source-map',
module: {
rules: [
{
test: /\.(ts|js)$/,
exclude: path.resolve(__dirname, 'node_modules'),
enforce: 'post',
use: [
{
loader: 'istanbul-instrumenter-loader',
options: {
esModules: true
}
}
]
}
]
}
});

module.exports = function (config) {
config.set({
Expand All @@ -24,7 +45,6 @@ module.exports = function (config) {

// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
// node_modules must not be webpacked or else Karma will fail to load frameworks
preprocessors: {
'tests/index.js': ['webpack', 'sourcemap']
},
Expand All @@ -39,41 +59,7 @@ module.exports = function (config) {
fixWebpackSourcePaths: true
},

webpack: {
mode: 'development',
devtool: 'inline-source-map',
resolve: {
extensions: ['.ts', '.js']
},module: {
rules: [
{
test: /\.(ts|js)$/,
include: path.resolve(__dirname, 'src'),
exclude: path.resolve(__dirname, 'node_modules'),
loader: 'ts-loader'
},// instrument only testing sources with Istanbul
{
test: /\.(ts|js)$/,

exclude: path.resolve(__dirname, 'node_modules'),enforce: 'post',
use: [
{
loader: 'istanbul-instrumenter-loader',
options: { esModules: true }
}
]
}
]
},
plugins: [
new webpack.DefinePlugin({
__VERSION__: JSON.stringify(pkgJson.version),
__USE_SUBTITLES__: JSON.stringify(true),
__USE_ALT_AUDIO__: JSON.stringify(true),
__USE_EME_DRM__: JSON.stringify(true)
})
]
},
webpack: mergeConfig,

// web server port
port: 9876,
Expand Down

0 comments on commit 0bbb9b8

Please sign in to comment.