mailtrap-plugin 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,15 @@
1
+ /*!
2
+ * mime-db
3
+ * Copyright(c) 2014 Jonathan Ong
4
+ * Copyright(c) 2015-2022 Douglas Christopher Wilson
5
+ * MIT Licensed
6
+ */
7
+
8
+ /*!
9
+ * mime-types
10
+ * Copyright(c) 2014 Jonathan Ong
11
+ * Copyright(c) 2015 Douglas Christopher Wilson
12
+ * MIT Licensed
13
+ */
14
+
15
+ /*! Axios v1.13.2 Copyright (c) 2025 Matt Zabriskie and contributors */
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "mailtrap-plugin",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "Mailtrap plugin to Flow requests",
5
- "main": "dist/index.js",
5
+ "main": "./dist/node-bundle.js",
6
+ "browser": "./dist/browser-bundle.js",
6
7
  "types": "dist/index.d.ts",
7
8
  "type": "module",
8
9
  "scripts": {
9
10
  "build": "webpack",
10
- "prepublish": "pnpm run build",
11
11
  "preinstall": "pnpm run build",
12
12
  "start": "tsx src/index.ts",
13
13
  "test": "jest ./tests/*.spec.ts"
@@ -1,8 +1,24 @@
1
1
  const path = require("path");
2
2
 
3
- module.exports = {
4
- entry: "./src/index.ts", // Your main entry file
5
- mode: "production", // Use 'development' for dev, 'production' for final output
3
+ // Helper to get __dirname equivalent in ESM
4
+ // const __filename = fileURLToPath(import.meta.url);
5
+ // const __dirname = path.dirname(__filename);
6
+
7
+ const commonConfig = {
8
+ entry: "./src/index.ts",
9
+ mode: "production",
10
+ // Shared output settings
11
+ output: {
12
+ path: path.resolve(__dirname, "dist"),
13
+ library: {
14
+ name: "AlertMessage",
15
+ type: "var",
16
+ },
17
+ },
18
+ // Ensure we can resolve ESM modules strictly
19
+ resolve: {
20
+ extensions: ["ts", ".js", ".mjs"],
21
+ },
6
22
  module: {
7
23
  rules: [
8
24
  {
@@ -12,13 +28,73 @@ module.exports = {
12
28
  },
13
29
  ],
14
30
  },
15
- resolve: {
16
- extensions: [".ts", ".js"],
31
+
32
+ // Add other loaders (e.g., Babel) if needed
33
+ };
34
+
35
+ // Configuration for Node.js bundle
36
+ const nodeConfig = {
37
+ ...commonConfig,
38
+ target: "node", // Target Node.js environment
39
+ output: {
40
+ ...commonConfig.output,
41
+ filename: "node-bundle.js",
42
+ library: {
43
+ type: "module", // Output as an ES module
44
+ },
45
+ },
46
+ // Tells webpack to externalize node_modules
47
+ // (typically you don't bundle them for Node)
48
+ externalsPresets: { node: true },
49
+ experiments: {
50
+ outputModule: true, // Enable experimental output module support
17
51
  },
52
+ };
53
+
54
+ // Configuration for Browser bundle
55
+ const browserConfig = {
56
+ ...commonConfig,
57
+ target: "web", // Target web environment
18
58
  output: {
19
- filename: "bundle.js",
20
- path: path.resolve(__dirname, "dist"),
21
- library: "MailtrapPlugin",
22
- libraryTarget: "umd",
59
+ ...commonConfig.output,
60
+ filename: "browser-bundle.js",
61
+ // You can use 'module' here as well, but 'umd' or 'assign'
62
+ // are more flexible for general browser usage (e.g., script tag or module import)
63
+ // 'module' requires <script type="module">
64
+ library: {
65
+ ...commonConfig.output.library,
66
+ type: "umd",
67
+ },
68
+ },
69
+ experiments: {
70
+ outputModule: true, // Enable experimental output module support
23
71
  },
24
72
  };
73
+
74
+ module.exports = [nodeConfig, browserConfig];
75
+
76
+ // module.exports = {
77
+ // entry: "./src/index.ts", // Your main entry file
78
+ // mode: "production", // Use 'development' for dev, 'production' for final output
79
+ // module: {
80
+ // rules: [
81
+ // {
82
+ // test: /\.ts$/,
83
+ // use: "ts-loader",
84
+ // exclude: /node_modules/,
85
+ // },
86
+ // ],
87
+ // },
88
+ // resolve: {
89
+ // extensions: [".ts", ".js"],
90
+ // },
91
+ // output: {
92
+ // filename: "bundle.js",
93
+ // path: path.resolve(__dirname, "dist"),
94
+ // library: {
95
+ // name: "AlertMessage",
96
+ // type: "var",
97
+ // },
98
+ // libraryTarget: "umd",
99
+ // },
100
+ // };