Jump to content
Search Community

Compiling causes error: Cannot assign to read only property 'window' of object '#<Window>'

carljohnston.uk test
Moderator Tag

Recommended Posts

Hi all,
This is my first time adding GSAP 3 into a project, and it seems to be causing some grief.

I'm using Gulp to compile a bunch of scripts, some of which are being referenced directly from the "node_modules" directory.
The compilation is fine, but even before I reference GSAP anywhere in my scripts, I'm getting the following error in my inspector:
 

Cannot assign to read only property 'window' of object '#<Window>'

Any ideas what I'm doing wrong?

Link to comment
Share on other sites

Hm, it's tough to troubleshoot blind - can you provide a reduced test case that'd allow us to see that error on our end? Do you know what line is triggering that error? Are you using any plugins and if so, did you register them first? We'd love to help, but we need more info :)

 

Link to comment
Share on other sites

It compiles without problem, however the error occurs when looking at the console in the inspector.

Here's how I have my environment set up

Folder structure:

|- node_modules/
|- gulpfile.js


gulpfile.js:

const {src, dest} = require('gulp'),
rename = require('gulp-rename'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat'),
babel = require('gulp-babel'),
uglify = require('gulp-uglify');

const fe_js = () => {

  return src(`./node_modules/gsap/dist/gsap.min.js`,)
    .pipe(sourcemaps.init())
    .pipe(concat(`scripts.js`))
    .pipe(babel({
      presets: ['@babel/env']
    }))
    .pipe(uglify())
    .pipe(rename({suffix: '.min'}))
    .pipe(sourcemaps.write('./'))
    .pipe(dest(`./assets/js`))
};

exports.default = series(fe_js);


Thanks in advance.

Link to comment
Share on other sites

15 hours ago, carljohnston.uk said:

It compiles without problem, however the error occurs when looking at the console in the inspector.

Here's how I have my environment set up

Folder structure:


|- node_modules/
|- gulpfile.js


gulpfile.js:


const {src, dest} = require('gulp'),
rename = require('gulp-rename'),
sourcemaps = require('gulp-sourcemaps'),
concat = require('gulp-concat'),
babel = require('gulp-babel'),
uglify = require('gulp-uglify');

const fe_js = () => {

  return src(`./node_modules/gsap/dist/gsap.min.js`,)
    .pipe(sourcemaps.init())
    .pipe(concat(`scripts.js`))
    .pipe(babel({
      presets: ['@babel/env']
    }))
    .pipe(uglify())
    .pipe(rename({suffix: '.min'}))
    .pipe(sourcemaps.write('./'))
    .pipe(dest(`./assets/js`))
};

exports.default = series(fe_js);


Thanks in advance.


Update: It seems that the error is occurring at the point where Babel is compiling the code.

Link to comment
Share on other sites

Yeah, I kinda doubt it's a GSAP issue. If you still need some help, please provide a reduced test case. Maybe put a project on github or something? 

 

I noticed you have src(`./node_modules/gsap/dist/gsap.min.js`,) and there's a comma at the end but there probably shouldn't be. Also, have you tried swapping that out for src(`./node_modules/gsap/index.js`)? 

 

I transpile GSAP using babel and it works fine. 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...