Skip to content

Commit

Permalink
add bundler
Browse files Browse the repository at this point in the history
  • Loading branch information
b3hr4d committed Feb 24, 2024
1 parent 41fbcd3 commit a0a9727
Show file tree
Hide file tree
Showing 7 changed files with 894 additions and 1,879 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ examples/candid-ui
examples/*/deps/candid
docs
.nx
.parcel-cache
bundle
12 changes: 7 additions & 5 deletions examples/javascript/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
{
"name": "javacript",
"scripts": {
"start": "parcel src/index.html"
"start": "webpack serve --mode development --open",
"build": "webpack --mode production"
},
"dependencies": {
"@ic-reactor/core": "^*"
},
"devDependencies": {
"@parcel/resolver-default": "^2.11.0",
"parcel": "^2.11.0",
"process": "^0.11.10"
"html-webpack-plugin": "^5.0.0",
"webpack": "^5.0.0",
"webpack-cli": "^4.0.0",
"webpack-dev-server": "^4.0.0"
}
}
}
31 changes: 31 additions & 0 deletions examples/javascript/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const path = require("path")
const HtmlWebpackPlugin = require("html-webpack-plugin")

module.exports = {
entry: "./src/main.js",
output: {
path: path.resolve(__dirname, "dist"),
filename: "bundle.js",
},
plugins: [
new HtmlWebpackPlugin({
template: "src/index.html", // Update this to point to your HTML file
}),
],
resolve: {
extensions: [".tsx", ".ts", ".js"],
modules: [path.resolve(__dirname, "node_modules"), "node_modules"],
},
devServer: {
static: {
directory: path.join(__dirname, "dist"),
},
compress: true,
port: 3000,
},
module: {
rules: [
// You can add loaders here for other file types (CSS, SASS, images, etc.)
],
},
}
15 changes: 11 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"author": "Behrad Deylami <b3hr4d@live.com>",
"license": "MIT",
"scripts": {
"bundle": "lerna run bundle",
"build": "lerna run build",
"clean": "lerna run clean",
"lerna-publish": "yarn clean && yarn build && lerna publish",
Expand All @@ -31,10 +32,10 @@
"e2e"
],
"devDependencies": {
"@babel/core": "7.23",
"@babel/preset-env": "7.23",
"@babel/core": "^7.23.9",
"@babel/preset-env": "^7.23.9",
"@babel/preset-react": "7.23",
"@babel/preset-typescript": "7.23",
"@babel/preset-typescript": "^7.23.3",
"@dfinity/agent": "^1.0",
"@dfinity/auth-client": "^1.0",
"@dfinity/candid": "^1.0",
Expand All @@ -51,11 +52,14 @@
"@types/xmlhttprequest": "^1",
"@typescript-eslint/eslint-plugin": "^7.0",
"@typescript-eslint/parser": "^7.0",
"@typescript-eslint/type-utils": "^7.0.2",
"babel-loader": "^9.1.3",
"eslint": "^8.56",
"eslint-config-prettier": "^9.1",
"eslint-plugin-jest": "^27.9",
"eslint-plugin-prettier": "^4",
"fake-indexeddb": "5.0.1",
"html-webpack-plugin": "^5.6.0",
"jest": "29.7",
"jest-fetch-mock": "^3.0",
"lerna": "^8",
Expand All @@ -73,7 +77,10 @@
"typedoc-plugin-include-example": "^1.2.0",
"typedoc-plugin-mdn-links": "^3.1.16",
"typescript": "^5.3",
"webpack": "^5.90.3",
"webpack-cli": "^5.1.4",
"webpack-dev-server": "^5.0.2",
"whatwg-fetch": "3.6",
"xmlhttprequest": "^1.8"
}
}
}
1 change: 1 addition & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"scripts": {
"test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest",
"start": "tsc watch",
"bundle": "webpack --config webpack.config.js --mode production",
"build": "npx tsc",
"clean": "npx rimraf dist"
},
Expand Down
37 changes: 37 additions & 0 deletions packages/core/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* eslint-disable @typescript-eslint/no-var-requires */
const path = require("path")

module.exports = {
entry: "./src/index.ts", // Your entry point file
output: {
path: path.resolve(__dirname, "bundle"),
filename: "bundle.js", // Output file
library: {
name: "@ic-reactor", // Exported library name
type: "umd", // Universal module definition
},
},
module: {
rules: [
{
test: /\.tsx?$/,
use: {
loader: "babel-loader",
options: {
presets: ["@babel/preset-env", "@babel/preset-typescript"],
},
},
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [".tsx", ".ts", ".js"],
modules: [path.resolve(__dirname, "node_modules"), "node_modules"],
},
// If there are specific modules you still want to leave as external:
externals: {
// "react": "React",
// Define externals here
},
}
Loading

0 comments on commit a0a9727

Please sign in to comment.