From 6980e91b422b4bdcd9694e92666ac3184a606076 Mon Sep 17 00:00:00 2001 From: Jake Fried Date: Mon, 22 Jun 2020 21:05:33 -0400 Subject: [PATCH] Luxonless binary should not contain any luxon imports. Uses NormalModuleReplacement to swap luxon with a fake. --- src/fake-luxon.ts | 5 +++++ webpack.config.js | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 src/fake-luxon.ts diff --git a/src/fake-luxon.ts b/src/fake-luxon.ts new file mode 100644 index 00000000..42b1a6fd --- /dev/null +++ b/src/fake-luxon.ts @@ -0,0 +1,5 @@ +export const DateTime = { + fromJSDate() { + throw new TypeError(); + } +}; diff --git a/webpack.config.js b/webpack.config.js index 42e04419..a764dd9f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -54,9 +54,9 @@ const rruleConfig = Object.assign({ rrule: path.join(paths.source, "index.ts"), 'rrule.min': path.join(paths.source, "index.ts") }, - externals: { - luxon: 'luxon' - }, + plugins: [ + new webpack.NormalModuleReplacementPlugin(/^luxon$/, './fake-luxon.ts'), + ] }, commonConfig); const rruleWithLuxonConfig = Object.assign({