JK0N / tensorflow-image-recognition-chrome-extension

Chrome browser extension for using TensorFlow image recognition on web pages

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot use import statement outside a module error when loading chrome extension

aimanuslim opened this issue · comments

Hi, I copied the manifest.json file out of dist into the root folder and load the whole folder unpacked into chrome. (I cant load just the manifest in the dist folder, its giving me other errors).

But now, I am getting this error below regarding not able to import statement outside of module. Is this a new thing with chrome extensions?


Uncaught SyntaxError: Cannot use import statement outside a module
Context
_generated_background_page.html
Stack Trace
src/background.js:1 (anonymous function)

import 'babel-polyfill'; <--- this line is highlighted indicating its the cause of the error
import * as tf from '@tensorflow/tfjs';
import { IMAGENET_CLASSES } from './imagenet_classes';

const MOBILENET_MODEL_PATH = 'https://storage.googleapis.com/tfjs-models/tfjs/mobilenet_v1_0.25_224/model.json';
const IMAGE_SIZE = 224;
const TOPK_PREDICTIONS = 10;

class BackgroundProcessing {

I've just found this project today, because I was having a hard time getting TensorFlow to work with my Google Extension. But when I try to install this extension, I'm seeing this same problem:

Uncaught SyntaxError: Cannot use import statement outside a module
Context
_generated_background_page.html
Stack Trace
src/background.js:1 (anonymous function)

Does this Chrome Extension work in current versions of Chrome? I'm running Chrome Version 120.0.6099.225.