You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Apr 8, 2020. It is now read-only.
I have extended one of your templates and added the following NPM scripts so that I can write my Webpack configuration using TypeScript which has a number of advantages:
This totally works and Webpack is happy with my JavaScript file generated from TypeScript however the WebpackDevMiddleware fails to run with the error:
One or more errors occurred. (TypeError: Cannot read property 'publicPath' of undefined
My TypeScript looks like this:
import * as path from "path";
import * as webpack from "webpack";
import { IArguments, INewConfiguration, INewConfigurationBuilder } from "./webpack.common";
const configurationBuilder: INewConfigurationBuilder =
(env: IArguments): INewConfiguration => {
const configuration: INewConfiguration = {
// ...
};
return configuration;
};
export default configurationBuilder;
This outputs the following JavaScript:
"use strict";
exports.__esModule = true;
var path = require("path");
var webpack = require("webpack");
var configurationBuilder = function (env) {
var configuration = {
// ...
};
return configuration;
};
exports["default"] = configurationBuilder;
The key difference is the last line of code. I've experimented with changing it and the WebpackDevMiddleware only works when it is module.exports = configurationBuilder;. To generate that line in TypeScript I have to use export = configurationBuilder; which is invalid TypeScript because the default tsconfig.json file has module set to es2015.
The key point is that Webpack supports exports["default"] = configurationBuilder;, so the WebpackDevMiddleware should too.
The text was updated successfully, but these errors were encountered:
I have extended one of your templates and added the following NPM scripts so that I can write my Webpack configuration using TypeScript which has a number of advantages:
This totally works and Webpack is happy with my JavaScript file generated from TypeScript however the
WebpackDevMiddleware
fails to run with the error:My TypeScript looks like this:
This outputs the following JavaScript:
The key difference is the last line of code. I've experimented with changing it and the
WebpackDevMiddleware
only works when it ismodule.exports = configurationBuilder;
. To generate that line in TypeScript I have to useexport = configurationBuilder;
which is invalid TypeScript because the defaulttsconfig.json
file hasmodule
set toes2015
.The key point is that Webpack supports
exports["default"] = configurationBuilder;
, so theWebpackDevMiddleware
should too.The text was updated successfully, but these errors were encountered: