diff --git a/Dockerfile b/Dockerfile index b5591e0..67d8070 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ -ARG NODE_IMAGE=node:20.11.1-slim -ARG PNPM_VERSION=9 +ARG NODE_IMAGE=node:20 +ARG PNPM_VERSION=9.12.3 ARG NODE_PLATFORM=linux/amd64 FROM --platform=${NODE_PLATFORM} ${NODE_IMAGE} as nodejs diff --git a/package.json b/package.json index 8e63a50..7297a03 100644 --- a/package.json +++ b/package.json @@ -39,6 +39,7 @@ "@types/react-dom": "18.3.1", "@typescript-eslint/eslint-plugin": "^8.15.0", "@typescript-eslint/parser": "^8.15.0", + "buffer": "^6.0.3", "copy-webpack-plugin": "^12.0.2", "css-loader": "^7.1.2", "eslint-plugin-react": "^7.37.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index aeab646..23e63e7 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -69,6 +69,9 @@ importers: '@typescript-eslint/parser': specifier: ^8.15.0 version: 8.15.0(eslint@9.15.0)(typescript@5.7.2) + buffer: + specifier: ^6.0.3 + version: 6.0.3 copy-webpack-plugin: specifier: ^12.0.2 version: 12.0.2(webpack@5.96.1) @@ -1939,6 +1942,9 @@ packages: balanced-match@2.0.0: resolution: {integrity: sha512-1ugUSr8BHXRnK23KfuYS+gVMC3LB8QGH9W1iGtDPsNWoQbgtXSExkBu2aDR4epiGWZOjZsj6lDl/N/AqqTC3UA==} + base64-js@1.5.1: + resolution: {integrity: sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==} + binary-extensions@2.3.0: resolution: {integrity: sha512-Ceh+7ox5qe7LJuLHoY0feh3pHuUDHAcRUeyL2VYghZwfpkNIy/+8Ocg0a3UuSoYzavmylwuLWQOf3hl0jjMMIw==} engines: {node: '>=8'} @@ -1970,6 +1976,9 @@ packages: buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} + buffer@6.0.3: + resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} + bytes@1.0.0: resolution: {integrity: sha512-/x68VkHLeTl3/Ll8IvxdwzhrT+IyKc52e/oyHhA2RwqPqswSnjVbSddfPRwAsJtbilMAPSRWwAlpxdYsSWOTKQ==} @@ -8350,6 +8359,8 @@ snapshots: balanced-match@2.0.0: {} + base64-js@1.5.1: {} + binary-extensions@2.3.0: {} body@5.1.0: @@ -8387,6 +8398,11 @@ snapshots: buffer-from@1.1.2: {} + buffer@6.0.3: + dependencies: + base64-js: 1.5.1 + ieee754: 1.2.1 + bytes@1.0.0: {} calculate-size@1.1.1: {} diff --git a/src/trace/.config/webpack/webpack.config.ts b/src/trace/.config/webpack/webpack.config.ts index d775dad..7b7b3dd 100644 --- a/src/trace/.config/webpack/webpack.config.ts +++ b/src/trace/.config/webpack/webpack.config.ts @@ -9,7 +9,7 @@ import CopyWebpackPlugin from 'copy-webpack-plugin'; import LiveReloadPlugin from 'webpack-livereload-plugin'; import path from 'node:path'; import ReplaceInFileWebpackPlugin from 'replace-in-file-webpack-plugin'; -import type { Configuration } from 'webpack'; +import { type Configuration, ProvidePlugin } from 'webpack'; import { getPackageJson, getPluginJson, hasReadme, getEntries, isWSL } from './utils'; import { SOURCE_DIR, DIST_DIR } from './constants'; @@ -27,7 +27,7 @@ const config = async (env): Promise => { context: path.join(process.cwd(), SOURCE_DIR), - devtool: env.production ? 'source-map' : 'eval-source-map', + devtool: 'source-map', entry: { ...(await getEntries()), @@ -59,8 +59,8 @@ const config = async (env): Promise => { // Mark legacy SDK imports as external if their name starts with the "grafana/" prefix ({ request }, callback) => { const prefix = 'grafana/'; - const hasPrefix = request => request.indexOf(prefix) === 0; - const stripPrefix = request => request.substr(prefix.length); + const hasPrefix = (request) => request.indexOf(prefix) === 0; + const stripPrefix = (request) => request.substr(prefix.length); if (hasPrefix(request)) { return callback(undefined, stripPrefix(request)); @@ -128,6 +128,9 @@ const config = async (env): Promise => { uniqueName: pluginJson.id, }, plugins: [ + new ProvidePlugin({ + Buffer: ['buffer', 'Buffer'], + }), new CopyWebpackPlugin({ patterns: [ // If src/README.md exists use it; otherwise the root README @@ -181,7 +184,7 @@ const config = async (env): Promise => { modules: [path.resolve(process.cwd(), 'src'), 'node_modules'], unsafeCache: true, fallback: { - buffer: false, + buffer: require.resolve('buffer'), fs: false, stream: false, http: false,