Angular 8
Closed this issue · 5 comments
./node_modules/libflacjs/index.js 52:8-55
Critical dependency: the request of a dependency is an expression
Error: "Uncaught (in promise): ReferenceError: process is not defined
./node_modules/libflacjs/index.js
how did you include the library?
did you follow the README for webpack?
i.e. something like
var Flac = require('libflacjs/dist/libflac.js');
Hello!
Yes, of course, I connected the library as in the documentation.
var Flac = require ('libflacjs / dist / libflac.js');
Here is a message:
./node_modules/libflacjs/dist/libflac.js 32: 23-26
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted
hmm, I tried to reproduce the error, but for me, there only was the warning message (Critical dependency: require function ...
), no actual error
The warning is due to the fact that webpack
(the build tool used by Angular) has problems with handling the UMD-wrapper of libflac.js, but it should still compile (and work)
I tested this by creating a new Angular 8 example app (via ng new
) and some simple code for decoding a FLAC file (based on the example code).
The only (small) difference was, that for including libflac.js
I did not use require
, but an import
statement like
import * as Flac from 'libflacjs/dist/libflac.js';
If there are still problems, I think I would need to see the actual code/configuration in order to find out, what is wrong.
Thank!
helped
import * as Flac from 'libflacjs / dist / libflac.js';
a warning remains, but the project compiles fine.
Can you help port an example?
https://github.com/mmig/speech-to-flac/blob/master/encoder.js
to Angular 8.
I need to write from a microphone in flac format to send to GoogleSpeech.
Thanks again!
I did not really test it, but for "converting" the encoder script to Angular 8, you probably only need to change the script-loading statement from
importScripts('libflac3-1.3.2.min.js');
to something like
var Flac = require('libflacjs/dist/libflac.js');
The bigger challenge is probably to get Angular/webpack to compile the worker-script as a separate script-file.
I updated the README with some basic instructions for doing this in a project built with webpack
, see README/webworker with webpack
... but the problem is that Angular 8 does provide an easy way to modify the project's webpack
configuration
One way for doing this, would be to use @angular-builders/custom-webpack and changing angular.json
etc.