Skip to content

Commit

Permalink
fix: remove webpack-inject-plugin dependency
Browse files Browse the repository at this point in the history
As mentioned in #454
  • Loading branch information
Andrew Richardson committed Aug 11, 2023
1 parent f527f75 commit 21de161
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 35 deletions.
5 changes: 1 addition & 4 deletions Resources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"google-closure-library": "^20220104.0.0",
"gulp": "^4.0.2",
"gulp-rename": "^2.0.0",
"gulp-uglify": "^3.0.2",
"gulp-typescript": "^6.0.0-alpha.1",
"gulp-uglify": "^3.0.2",
"gulp-wrap": "^0.15.0",
"jasmine": "^4.0.2",
"tsd": "^0.19.1",
Expand All @@ -47,8 +47,5 @@
"test": "npm run build && npm run test:types && phantomjs js/run_jsunit.js js/router_test.html",
"test:types": "tsd",
"prepublish": "npm run build"
},
"dependencies": {
"webpack-inject-plugin": "^1.5.5"
}
}
46 changes: 23 additions & 23 deletions Resources/public/js/router.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
(function (root, factory) {
var routing = factory();
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], routing.Routing);
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = routing.Routing;
} else {
// Browser globals (root is window)
root.Routing = routing.Routing;
root.fos = {
Router: routing.Router
};
}
}(this, function () {
var exports = {};
(function (root, factory) {
var routing = factory();
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define([], routing.Routing);
} else if (typeof module === 'object' && module.exports) {
// Node. Does not work with strict CommonJS, but
// only CommonJS-like environments that support module.exports,
// like Node.
module.exports = routing.Routing;
} else {
// Browser globals (root is window)
root.Routing = routing.Routing;
root.fos = {
Router: routing.Router
};
}
}(this, function () {
var exports = {};
"use strict";
exports.__esModule = true;
exports.Routing = exports.Router = void 0;
Expand Down Expand Up @@ -277,7 +277,7 @@ var Router = /** @class */ (function () {
exports.Router = Router;
exports.Routing = new Router();
exports["default"] = exports.Routing;


return { Router: exports.Router, Routing: exports.Routing };
}));


return { Router: exports.Router, Routing: exports.Routing };
}));
2 changes: 1 addition & 1 deletion Resources/public/js/router.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 12 additions & 7 deletions Resources/webpack/FosRouting.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
const fs = require('fs');
const path = require('path');
const util = require('util');

const InjectPlugin = require('webpack-inject-plugin').default;
const webpack = require("webpack");

const execFile = util.promisify(require('child_process').execFile);
const readFile = util.promisify(fs.readFile);
Expand Down Expand Up @@ -90,11 +89,17 @@ class FosRouting {
}
});

new InjectPlugin(() => {
return 'import Routing from "fos-router";' +
'import routes from '+JSON.stringify(this.finalTarget)+';' +
'Routing.setRoutingData(routes);';
}).apply(compiler);
new webpack.BannerPlugin({
entryOnly: true,
include: this.finalTarget ? this.finalTarget + ".js" : /\.js$/,
raw: true,
banner:
'import Routing from "fos-router";' +
"import routes from " +
JSON.stringify(this.finalTarget) +
";" +
"Routing.setRoutingData(routes);",
}).apply(compiler);
}
}

Expand Down

0 comments on commit 21de161

Please # to comment.