Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update webpack to use babel loader with support for TS. #2119

Merged
merged 9 commits into from Feb 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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