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 8 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
48 changes: 42 additions & 6 deletions karma.conf.js
Expand Up @@ -4,6 +4,7 @@
const pkgJson = require('./package.json');
const webpack = require('webpack');
const path = require('path');
const importHelper = require('@babel/helper-module-imports');

module.exports = function (config) {
config.set({
Expand All @@ -24,7 +25,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 @@ -44,18 +44,54 @@ module.exports = function (config) {
devtool: 'inline-source-map',
resolve: {
extensions: ['.ts', '.js']
},module: {
},
module: {
itsjamie marked this conversation as resolved.
Show resolved Hide resolved
rules: [
{
test: /\.(ts|js)$/,
include: path.resolve(__dirname, 'src'),
exclude: path.resolve(__dirname, 'node_modules'),
loader: 'ts-loader'
},// instrument only testing sources with Istanbul
loader: 'babel-loader',
options: {
babelrc: false,
presets: [
'@babel/preset-typescript',
['@babel/preset-env', {
loose: true,
modules: false,
targets: {
browsers: [
'chrome >= 47',
'firefox >= 51',
'ie >= 11',
'safari >= 8',
'ios >= 8',
'android >= 4'
]
}
}]
],
plugins: [
['@babel/plugin-proposal-class-properties', {
loose: true
}],
'@babel/plugin-proposal-object-rest-spread',
{
visitor: {
CallExpression: function (espath) {
if (espath.get('callee').matchesPattern('Number.isFinite')) {
espath.node.callee = importHelper.addNamed(espath, 'isFiniteNumber', path.resolve('src/polyfills/number-isFinite'));
}
}
}
}
]
}
}, // instrument only testing sources with Istanbul
{
test: /\.(ts|js)$/,

exclude: path.resolve(__dirname, 'node_modules'),enforce: 'post',
exclude: path.resolve(__dirname, 'node_modules'),
enforce: 'post',
use: [
{
loader: 'istanbul-instrumenter-loader',
Expand Down