Skip to content

Babel uses reserved keyword default when compiling #21

@p6l-richard

Description

@p6l-richard

When installing additional npm packages, some of them get transpiled using .default to access an object. However, in GAS default is a reserved keyword resulting in an error.

Expected Behavior

Webpack should use Babel to transpile Object property accessing using the bracket notation instead of the dot notation.

Current Behavior

clasp push throws error

{
errors: [
    {
      message: 'Syntax error: Missing name after . operator. line: XXX file: bundle.js',
      domain: 'global',
      reason: 'badRequest'
    }
  ]
}

bundle.js:

//...
Object.defineProperty(exports, "DataFrame", {
  enumerable: true,
  get: function get() {
    return _dataframe.default;
  }
});
//...

index.js:

import DataFrame from 'dataframe-js';
//...
const response = () => {
  return JSON.parse(UrlFetchApp.fetch(url, { method: 'get' }));
}
DataFrame.fromJSON(response()).then(df => {
  Logger.log(df);
 });

Possible Solution

Beginner friendly explanation for installing additional packages that might conflict with the default keyword or include babel-preset-gas in your project setup.

Steps to Reproduce

  1. clone apps-script-starter
  2. cd to project, npm install dataframe-js
  3. use dataframe-js functionality
  4. npm run deploy

Context (Environment)

I am a beginner wanting to set up an environment to develop in GAS using JavaScript. Since I'm handling data from APIs to be pushed to a Google Sheet, I would like to work with data frames to make data handling easier.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions