I got some help and figured I'd share my solution here in case anyone finds
this later. This is a pretty minimal config that will build a file in
src/index.ts that imports apache-arrow from the full install (npm i
apache-arrow). You can see notes below where I wasn't having success with
the minimal typescript version. There's a webpack and a typescript config.

webpack.config.json:

const path = require('path');

module.exports = {
  target: 'web',
  mode: 'development',
  entry: './src/index.ts',
  optimization: {
    minimize: false,
  },
  output: {
    path: path.resolve(__dirname, 'dist'),
    filename: "bundle.js",
  },
  resolve: {
    // Add ".ts" and ".tsx" as resolvable extensions.
    extensions: ['.ts', '.tsx', '.js', '.jsx', '.css'],
    // The below is unnecessary if we set the rule below for mjs files.
    // alias: {
    //   'apache-arrow': path.resolve(__dirname,
'node_modules/apache-arrow/Arrow.esnext.min.js'),
    //   // Doesn't build?
    //   // 'apache-arrow': path.resolve(__dirname,
'node_modules/@apache-arrow/ts/Arrow.ts'),
    // },
  },
  module: {
    rules: [
      // all files with a `.ts` or `.tsx` extension will be handled by
`ts-loader`
      {
        test: /\.tsx?$/,
        loader: "ts-loader"
      },
      {
        // This seems to mess with devtools - which now wants to find every
individual library!
        // But this is a way to make arrow work without the alias above
(which feels more hacky / brittle)
        test: /\.m?js$/,
        resolve: { fullySpecified: false },
      },
    ],
  }
};

tsconfig.json:

{
  "compilerOptions": {
    "rootDir": "src",
    "outDir": "dist",
    "target": "es2017",
    "lib": [
      "esnext",
      "dom.iterable",
      "dom"
    ],
    "module": "esnext",
    "moduleResolution": "node",
    "esModuleInterop": true,
    "strict": true,
    "sourceMap": true
  }
}

On Mon, Dec 13, 2021 at 2:46 PM Dav Clark <[email protected]> wrote:

> Hello,
>
> I know arrow can work in the browser due to the nice observableHQ
> notebooks about it. However, I'm currently struggling to get to the point
> where I can successfully even compile a simple front-end ts file with an
> apache-arrow import - using either the generic (`npm i apache-arrow`) or 
> @apache-arrow/ts
> or @apache-arrow/exnext-esm.
>
> I am happy to put up an example that does not work, but my guess is I'm
> missing something pretty basic here, and I've tried many different things.
> So, I could use guidance in terms of what would be a useful example here.
>
> Ideally, I'll use the ts-loader webpack. Ultimately, I'll be integrating
> with a Next.js application.
>
> Thank you!
> Dav
>

Reply via email to