Skip to content

Commit

Permalink
Copied webpack 5 types into plugins.temp.types.ts (#70)
Browse files Browse the repository at this point in the history
Assigned them as it should be from webpack.
Kept legacy code in place (should depreciate)
  • Loading branch information
Brian-McBride authored Mar 15, 2021
1 parent c362181 commit 463cef3
Show file tree
Hide file tree
Showing 5 changed files with 582 additions and 41 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
},
"devDependencies": {
"@types/jest": "^26.0.20",
"@types/node": "^14.14.33",
"@types/node": "^14.14.34",
"husky": "^5.1.3",
"jest": "^26.6.3",
"jest-mock-process": "^1.4.0",
"lint-staged": "^10.5.4",
"prettier": "^2.2.1",
"rimraf": "^3.0.2",
"ts-jest": "^26.5.3",
"ts-loader": "^8.0.17",
"ts-loader": "^8.0.18",
"tslint": "^5.20.1",
"tslint-immutable": "^6.0.1",
"typescript": "^4.2.3",
"webpack": "^5.24.4",
"webpack": "^5.25.1",
"webpack-cli": "^4.5.0"
},
"scripts": {
Expand Down
61 changes: 59 additions & 2 deletions src/__tests__/plugins.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe(`TsconfigPathsPlugin`, () => {
const SETTINGS: Configuration = {
mode: "development",
context: path.resolve(__dirname, "src"),
entry: `../../../example/src/index.ts`,
entry: `${__dirname}/../../example/src/index.ts`,
output: {
path: path.join(__dirname, "../../temp"),
filename: "bundle.js",
Expand Down Expand Up @@ -38,7 +38,7 @@ describe(`TsconfigPathsPlugin`, () => {
});
expect(testPlugin).toBeInstanceOf(TsconfigPathsPlugin);

const testSettings: webpack.Configuration = {
const testSettings: Configuration = {
...SETTINGS,
resolve: {
extensions: [".ts", ".tsx", ".js"],
Expand All @@ -60,4 +60,61 @@ describe(`TsconfigPathsPlugin`, () => {
done();
});
});

it(`Test to ensure Apply exists and is working`, async (done) => {
const webpackSettings: Configuration = {
entry: `${__dirname}/../../example/src/index.ts`,
target: "web",
output: {
path: path.join(__dirname, "../../temp"),
filename: "[name].js",
},
mode: "development",
resolve: {
extensions: [
".ts",
".tsx",
".js",
".jsx",
"ttf",
"eot",
"otf",
"svg",
"png",
"woff",
"woff2",
],
plugins: [
new TsconfigPathsPlugin({
configFile: `${__dirname}/../../example/tsconfig.json`,
}),
],
},
module: {
rules: [],
},
};
// Build compiler
const compiler = webpack(webpackSettings);
const pluginInstance = compiler?.options?.resolve?.plugins?.find(
(plugin) => plugin instanceof TsconfigPathsPlugin
);
if (!pluginInstance) {
return done(`TsconfigPathsPlugin not loaded in webpack settings`);
}
expect(pluginInstance instanceof TsconfigPathsPlugin).toBeTruthy();
expect((pluginInstance as TsconfigPathsPlugin).apply).toBeDefined();

// Run compiler
compiler.run((err, stats) => {
if (err) {
done(err);
return;
}
expect(stats).toBeDefined();
const details = stats?.toJson();
expect(details?.errorsCount).toEqual(0);
done();
});
});
});
Loading

0 comments on commit 463cef3

Please sign in to comment.