Can't merely import AWS amplify or aws appsync

Upon importing either of the libraries compiler throws errors. I believe both of them expect util package to be installed (appsync definitely does)
Amplify- https://www.npmjs.com/package/aws-amplify:

import Amplify from 'aws-amplify';
AssertionError [ERR_ASSERTION]: loading or loaded
    at Console.assert (console.js:194:23)
    at C:\Users\janat08\Dev\makpal\node_modules\steal\src\loader\loader-sans-promises.js:236:17
    at

appsync - https://www.npmjs.com/package/aws-appsync:

import AWSAppSyncClient from 'aws-appsync'
Error compiling
The load aws-appsync@1.0.23#lib/index already failed.

I guess that the issue there is dependency on util package that tries to bring node’s util to browser which steal doesn’t accept.

aws-appsync exports a module under the same name used above which will also not work. Justin mentioned https://github.com/stealjs/node-browser-builtins as way to replace util

The error you are seeing happens during a steal-tools build or during the app loading dynamically with steal.js?

donejs develop… how do you tell those apart?

Did the error happen while running steal-tools to build the app into one or more minified bundles? Or, are you just opening a development page and having steal load each file individually?

I belief development, if youre referring to donejs develop or build.

Did in dependencies of package.js after installing steal-builtins
“util”: “steal-builtins/builtin/util.js’”
Get the error:

Error: Could not load 'util@steal-builtins/builtin/util.js'#index'
Is this an npm module not saved in your package.json?
    at file:C:/Users/janat08/Dev/makpal/node_modules/steal/ext/npm-extension.js:379:20
    at C:\Users\janat08\Dev\makpal\node_modules\can-zone\lib\tasks.js:166:15
    at Task.run (C:\Users\janat08\Dev\makpal\node_modules\can-zone\lib\zone.js:38:17)
    at Zone.runTask (C:\Users\janat08\Dev\makpal\node_modules\can-zone\lib\zone.js:181:14)
    at C:\Users\janat08\Dev\makpal\node_modules\can-zone\lib\zone.js:282:15
    at C:\Users\janat08\Dev\makpal\node_modules\can-zone\lib\tasks.js:177:21
    at 

It appears to want to access index of that file, and contrary to documentation you indeed have to access steal-builtins.

It’s a bug, filed here: https://github.com/stealjs/steal/issues/1428

Should be an easy fix I think. Let’s take the discussion there.

Fixed in steal 1.12.2

btw imports still don’t work. They produce 404 errors for all of the modules of aws-amplify.

GET http://localhost:8080/node_modules/aws-amplify/lib/Cache.js 404 (Not Found)
Error: 0 : http://localhost:8080/node_modules/aws-amplify/lib/Analytics.js

The module [aws-amplify/lib/Analytics] couldn't be fetched.
Clicking the link in the stack trace below takes you to the import.
See https://stealjs.com/docs/StealJS.error-messages.html#404-not-found for more information.

  13 |  */
  14 | Object.defineProperty(exports, "__esModule", { value: true });
> 15 | var Analytics_1 = require("./Analytics");
     |                  ^
  16 | exports.Analytics = Analytics_1.default;
  17 | exports.AnalyticsClass = Analytics_1.AnalyticsClass;
  18 | exports.AWSPinpointProvider = Analytics_1.AWSPinpointProvider;


    at (:8080/node_modules/aws-amplify/lib/index.js:15)

reading the doc, it’s not that the package is missing form package.json, and I’m importing the default export with like 10 404s popping up for its’ properties.

@matthewp would you look at it?

This seems to work fine: https://gist.github.com/matthewp/48c384bde6e2c0517a15c44312958ff1

if you generate a project with donejs, than that happens.

on windows at least.

package.json

{
  "name": "aws",
  "version": "0.0.0",
  "description": "An awesome DoneJS app",
  "homepage": "",
  "repository": {
    "type": "git",
    "url": "git+https://github.com/donejs-user/aws.git"
  },
  "author": {
    "name": "zhan",
    "email": "jey.and.key@gmail.com",
    "url": "https://donejs.com"
  },
  "private": true,
  "scripts": {
    "test": "testee test.html --browsers firefox --reporter Spec",
    "start": "done-serve --port 8080",
    "develop": "done-serve --develop --port 8080",
    "build": "node build"
  },
  "main": "aws/index.stache!done-autorender",
  "files": [
    "src"
  ],
  "keywords": [
    "",
    "donejs-app"
  ],
  "steal": {
    "main": "aws/index.stache!done-autorender",
    "directories": {
      "lib": "src"
    },
    "configDependencies": [
      "live-reload",
      "node_modules/can-zone/register",
      "node_modules/steal-conditional/conditional"
    ],
    "plugins": [
      "done-css",
      "done-component",
      "steal-less",
      "steal-stache"
    ],
    "envs": {
      "server-production": {
        "renderingBaseURL": "/dist"
      }
    },
    "serviceBaseURL": ""
  },
  "dependencies": {
    "aws-amplify": "^0.4.5",
    "can-component": "^4.0.2",
    "can-connect": "^2.0.2",
    "can-define": "^2.0.1",
    "can-route": "^4.1.0",
    "can-route-pushstate": "^4.0.1",
    "can-set": "^1.5.1",
    "can-stache": "^4.1.0",
    "can-stache-route-helpers": "<2.0.0",
    "can-view-autorender": "^4.0.0",
    "can-zone": "^0.6.13",
    "done-autorender": "^2.0.0",
    "done-component": "^2.0.0",
    "done-css": "^3.0.2",
    "done-serve": "^2.0.0",
    "generator-donejs": "^2.1.0",
    "steal": "^1.6.5",
    "steal-less": "^1.2.2",
    "steal-stache": "^4.0.1"
  },
  "devDependencies": {
    "can-debug": "^1.0.0",
    "can-fixture": "^2.0.2",
    "donejs-cli": "^2.0.0",
    "funcunit": "^3.2.0",
    "steal-conditional": "^1.0.0",
    "steal-qunit": "^1.0.1",
    "steal-tools": "^1.11.3",
    "testee": "^0.7.0"
  },
  "license": "MIT"
}

Ok, I’ll investigate tomorrow

Here’s an example project where this is working: https://github.com/donejs/donejs-amplify-example-project

If you are seeing something different let me know.