nativescript webpack 폴리필 적용

Updated on

    // fallback apply
    webpack.mergeWebpack({
        resolve: {
            fallback: {
                "stream": require.resolve("stream-browserify"),
                "zlib": require.resolve("browserify-zlib"),
                "https": require.resolve("https-browserify"),
                "http": require.resolve("stream-http"),
                "assert": require.resolve("assert/"),
                "crypto": require.resolve("crypto-browserify"),
                "os": require.resolve("os-browserify/browser"),
                "path": require.resolve("path-browserify"),
                "process": require.resolve("process/browser"),
                "url": require.resolve("url/"),
                "buffer": require.resolve("buffer"),
                "util": require.resolve("util/"),
                "tty": require.resolve("tty-browserify"),
                "vm": require.resolve("vm-browserify"),
                "fs": false // fs 모듈은 브라우저 환경에서 사용되지 않기 때문에 false로 설정
            }
        },
        plugins: [
            new NormalModuleReplacementPlugin(/^node:/, (resource) => {
                resource.request = resource.request.replace(/^node:/, "");
            })
        ]
    });

nativescript webpack 폴리필 적용하는 방법이다. 디스코드 채널에서 찾았음. :(