Giter Site home page Giter Site logo

esri / ember-esri-loader Goto Github PK

View Code? Open in Web Editor NEW
10.0 17.0 6.0 2.3 MB

An Ember addon to allow lazy loading the ArcGIS API for JavaScript in Ember applications

Home Page: http://ember-esri-loader.surge.sh/

License: MIT License

JavaScript 85.36% HTML 6.69% CSS 0.79% Handlebars 7.16%
web-development ember ember-cli ember-addon arcgis-api esri-loader javascript module-loader

ember-esri-loader's Introduction

ember-esri-loader

An Ember addon that wraps the esri-loader library to allow lazy loading and preloading the ArcGIS API for JavaScript in Ember applications.

An example of preloading the ArcGIS API

View it live.

See the esri-loader README for more information on why this is needed.

Compatibility

  • Ember.js v3.20 or above
  • Ember CLI v3.20 or above
  • Node.js v12 or above

Installation

In your app's root folder run:

npm install esri-loader
ember install ember-esri-loader

Usage

Loading Modules from the ArcGIS API for JavaScript

Here's an example of how you could load and use the latest 4.x MapView and WebMap classes in a component to create a map:

// app/components/esri-map.js
export default Ember.Component.extend({
  layout,
  esriLoader: Ember.inject.service('esri-loader'),

  // once we have a DOM node to attach the map to...
  didInsertElement () {
    this._super(...arguments);
    // load the map modules
    this.get('esriLoader').loadModules(['esri/views/MapView', 'esri/WebMap']).then(modules => {
      if (this.get('isDestroyed') || this.get('isDestroying')) {
        return;
      }
      const [MapView, WebMap] = modules;
      // load the webmap from a portal item
      const webmap = new WebMap({
        portalItem: { // autocasts as new PortalItem()
          id: this.itemId
        }
      });
      // Set the WebMap instance to the map property in a MapView.
      this._view = new MapView({
        map: webmap,
        container: this.elementId
      });
    });
  },

  // destroy the map view before this component is removed from the DOM
  willDestroyElement () {
    if (this._view) {
      this._view.container = null;
      delete this._view;
    }
  }
});

See the esri-loader documentation on loading modules for more details.

Loading Styles

Before you can use the ArcGIS API in your app, you'll need to load the styles. See the esri-loader documentation on loading styles for more details.

Lazy Loading the ArcGIS API for JavaScript

The above code will lazy load the ArcGIS API for JavaScript the first time loadModules() is called. This means users of your application won't need to wait for the ArcGIS API to download until it is need.

Pre-loading the ArcGIS API for JavaScript

Alternatively, if you have good reason to believe that the user is going to transition to a map route, you may want to start pre-loading the ArcGIS API as soon as possible w/o blocking template rendering. You can add the following to the application route:

import { inject as service } from '@ember/service';
import Route from '@ember/routing/route';

export default class ApplicationRoute extends Route {
  @service esriLoader

  beforeModel() {
    // Preload the JS & CSS for the latest (4.x) version of the JSAPI
    this.esriLoader.loadScript({ css: true })
      .catch(err => {
        // TODO: better way of showing error
        window.alert(err.message || err);
      });
  }

}

Now you can use loadModules() in components to create maps or 3D scenes. Also, if you need to, you can use isLoaded() anywhere in your application to find out whether or not the ArcGIS API has finished loading.

esri-module-cache mixin

This addon also includes a mixin that can be help mitigate one of the primary pain points of using esri-loader: accessing modules is always asynchronous. That's fine for modules like esri/map where you expect to be using them in an asynchronous operation (like creating a map). However, it can be cumbersome when you just need something like a new Graphic() to add to that map.

Services or components that implement the esri-module-cache mixin can load all the modules they may need up front during an async operation (such as creating a map), and then use the mixin's cacheModules() function to store references to any of those modules so they don't have to be loaded again. Later the getCachedModule() and newClassInstance() functions can be used to synchronously access and use the modules that have already been loaded. For example:

// map-service.js
import Service, { inject as service } from '@ember/service';
import EsriModuleCacheMixin from 'ember-esri-loader/mixins/esri-module-cache';

export default Service.extend(EsriModuleCacheMixin, {
  esriLoader: service('esri-loader'),
  loadMap (elemendId, options) {
    return thigs.get('esriLoader').loadModules([
      'esri/map',
      'esri/Graphic'
    ]).then(([Map, Graphic]) => {
      // cache graphic module later for synchronous use
      this.cacheModules({ Graphic });
      // create and return the map instance
      return new Map(elementId, options);
    });
  },
  // NOTE: this will throw an error if it is called before loadMap()
  newGraphic (...args) {
    return this.newClassInstance('Graphic', ...args);
  }
});
// my-map/component.js
export default Component.extend({
  layout,
  mapService: service(),

  // once we have a DOM node to attach the map to...
  didInsertElement () {
    this._super(...arguments);
    // load the map
    this.get('mapService').loadMap(this.elementId, { basemap: 'gray' })
    .then(map => {
      this.map = map;
    })
  },
  actions: {
    addGraphic (x, y) {
      if (!this.map) {
        // can't call newGraphic() unles map has loaded
        // also no point in creating a gaphic if there's no map to add it to
        return;
      }
      const graphicJson = {
        geometry: {
          x,
          y,
          spatialReference: {
            wkid: 4326
          }
        },
        symbol: {
          color: [255, 0, 0, 128],
          size: 12,
          angle: 0,
          xoffset: 0,
          yoffset: 0,
          type: 'esriSMS',
          style: 'esriSMSSquare',
          outline: {
            color: [0, 0, 0, 255],
            width: 1,
            type: 'esriSLS',
            style: 'esriSLSSolid'
          }
        }
      };
      const graphic =
      this.get('mapService').newGraphic(graphicJson);
      this.map.graphics.add(graphic);
    }
  }

Configuration

Options

  • additionalFiles: list of strings or RegExp objects, defaults to []. Identifies additional files in which we should replace require and define. This can be particularly helpful if also using ember-auto-import 2.x, which places its modules in separate js files and attempts to capture the require and define the app is using. The configuration example above shows how to support ember-auto-import 2.x with the default webpack configuration, but you can add additional globs as necessary.

Using with ember-auto-import

If you are using ember-auto-import you will have to configure ember-auto-import to exclude any imports from esri-loader. Furthermore, if you are using ember-auto-import v2.x you will need to configure ember-esri-loader to process the ember-auto-import output using additionalFiles. To do so, add the following options in your ember-cli-build.js file:

// ember-cli-build.js

let app = new EmberApp(defaults, {
  autoImport: {
    // ember-esri-loader loads esri-loader with a script tag to prevent it from being rewritten to replace "require"
    // and "define" in the build pipeline.  We need to exclude it from ember-auto-import so that we don't pull it
    // back into the build pipeline when we import it ourselves.
    exclude: [ 'esri-loader' ],
  }
  'ember-esri-loader': {
    // this is only needed for ember-auto-import 2.x
    additionalFiles: [ /chunk\.app\..*\.js/ ],
  }
}

How It Works

This addon is an implementation of the "Dedicated Loader Module" pattern for Ember. It is a mashup of the ideas from angular2-esri-loader and ember-cli-amd. Like angular2-esri-loader, it creates a service that exposes functions that wrap calls to the esri-loader library to load the ArcGIS API and it's modules in promises. However, in order to avoid global namespace collisions with loader.js's require() and define() this addon also has to steal borrow from ember-cli-amd the code that finds and replaces those terms with their pig-latin counterparts in the build output. However unlike ember-cli-amd, it does not inject the ArcGIS for JavaScript in the page, nor does it use the ArcGIS API's Dojo loader to load the entire app.

Limitations

You cannot use ES2015 module syntax for ArcGIS API modules (i.e. import Map from 'esri/map';) with this addon. If you do not feel that your application would benefit from lazy-loading the ArcGIS API, and you'd prefer the cleaner abstraction of being able to use import statements, you can use ember-cli-amd.

Using this addon to load ArcGIS API for JavaScript v4.x modules in tests run in PhantomJS may cause global errors. Those errors did not happen when running the same tests in Chrome or FireFox.

Also, this addon cannot be used in an Ember twiddle.

Examples

In addition to ArcGIS Online applications such as ArcGIS Hub, the following open source applications use this addon:

MyStreet - A municipality viewer that allows users to input an address and receive information based on that location uses this addon to lazy load v3.x of the ArcGIS API only when an app uses a map.

The dummy application for this addon demonstrates how to pre-load v4.x of the ArcGIS API.

Development Instructions

Fork, Clone, and Install

  • fork and clone the repository
  • cd ember-esri-loader
  • npm install

Linting

  • npm run lint:hbs
  • npm run lint:js
  • npm run lint:js -- --fix

Running Tests

  • ember test – Runs the test suite on the current Ember version
  • ember test --server – Runs the test suite in "watch mode"
  • ember try:each – Runs the test suite against multiple Ember versions

Building

Issues

Find a bug or want to request a new feature? Please let us know by submitting an issue.

Contributing

Esri welcomes contributions from anyone and everyone. Please see our guidelines for contributing.

Licensing

Copyright 2017 Esri

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

A copy of the license is available in the repository's license.txt file.

ember-esri-loader's People

Contributors

dbouwman avatar dependabot[bot] avatar ember-tomster avatar ffaubry avatar gbochenek avatar mjuniper avatar timmorey avatar tomwayson avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ember-esri-loader's Issues

upgrade emebr

I'd have to figure out how to do this for an addon.

Make esriLoader.isLoaded a CP?

So far I've just copied the API from the Angular2 implementation of this pattern, and isLoaded is a function: https://github.com/ArcGIS/ember-esri-loader/blob/29dee26dfe75b4cf17500d3fcb159c922c10d462/addon/services/esri-loader.js#L5-L10

However, the current dummy app would certainly benefit from the service exposing a CP that that the controllers/templates could watch and update instead of having to manage that state in their own properties.

Not sure of best way to do that though b/c CP would have to depend on the existence of a global (require).

Maybe this would only help the dummy app. Maybe more trouble than it's worth.

production builds of 2.14.2 apps do not work at all

STR:

  • create a new 2.14.2 app
  • follow the installation and usage instructions
  • serve the app w/ ember s and it will run fine
  • server a production build w/ ember s -prod

The app shows a blank white page.

If you see integrity errors in the console like:

image

Then you can remove integrity attributes from script and link tags in index.html and you will see the the real errors:

image

@gbochenek noticed that the vendor script has:

var c = {
        loader: loader,
        efineday: define,
        requireModule: requireModule,
        equireray: require,
        requirejs: requirejs
    }

and that you can get the app running by replacing that with:

var c = {
        loader: loader,
        efineday: efineday,
        requireModule: requireModule,
        equireray: equireray,
        requirejs: requirejs
    }

Changing require to pig latin breaking tests

Using this addon and ember-cli-code-coverage together causes tests run with the coverage option to fail. The error is uncaught referenceError: require is not defined.

After a couple hours, commented out and yarn remove'd ember-esri-loader from my app, re-ran tests with the coverage option, and everything worked. Note: Running tests without that coverage mumbo-jumbo worked fine with ember-esri-loader installed.

Perhaps it's because ember-esri-loader is redefining require statements?

Similar issues to mine (but with other libraries redefining require) here.

Old Ember and Esri-loader versions

The latest release of ember-esri-loader uses an old version of Ember. And also an old version of Esri-loader library.

Can you guys please update this?

Thanks!

Try and demonstrate how to pre-load the JSAPI

If you have good reason to believe that the user is going to transition to a map route, probably want to start pre-loading the JSAPI as soon as possible w/o blocking the inital route's template rendering. The current code should work, just need to find the right hook in the route lifecycle and make sure the injected script tag doesn't need something like an async attribute to make sure it's not blocking rendering - I don't think it will, but want to try it out to test.

efineday is not a function error when using w/ ember-cli-stencil in production builds

Getting Uncaught (in promise) TypeError: a.efineday is not a function errors when using this w/
ember-cli-stencil (specifically w/ calcite-components), but only in production builds. Example:

https://coronavirus-response-alaska-dhss.hub.arcgis.com/datasets/covid-cases-out-of-state/data?uiVersion=5f51dc80921ca7850742e54353752c7a591cbdd6

image

The issue appears to be that we've added an exception to the regex for customElements.define(), but in a production build this addon is operating on the uglified code, so this statement:

customElements.define(tagName, proxyComponent(HostElement, cmpMeta, 1
        /* isElementConstructor */
        ))

is now a.define(c, he(u, r, 1)))

Maybe we can instruct the ember build to run this before uglify? That might cause other errors. (see #95 (comment))

Unknown issue following 3.0.0 update

We have a table gets populated with attributes from the points displayed on the map, showing at the lower part of the map. The attributes have about 10 columns that is working fine with the original v2.9.0 but now it only load 2 columns and looks like it is on a loop and keep loading. Data is in AGOL. Got this error when debugging and wonder if this provides a clue?

index.js:163 Uncaught Error: Assertion Failed: You must call `this._super(...arguments);` when overriding `init` on a framework object. Please update <crashmap@service:crashmapdata::ember413> to call `this._super(...arguments);` from `init`.
    at assert (index.js:163)
    at Class._proto.<computed> [as __ASSERT_INIT_WAS_CALLED__ember1564610496677861481332005__] (object.js:131)
    at sendEvent (metal.js:465)
    at initialize (core_object.js:107)
    at Function.create (core_object.js:686)
    at FactoryManager.create (container.js:554)
    at instantiateFactory (container.js:358)
    at _lookup (container.js:290)
    at Container.lookup (container.js:134)
    at Class.lookup (container_proxy.js:78)

npm updated the following dependencies as well:

Package: @ember/jquery

  • Specified: ^0.6.1

Package: ember-cli

  • Specified: ^3.11.0

Package: ember-cli-dependency-checker

  • Specified: ^3.2.0

Package: ember-cli-htmlbars

  • Specified: ^3.1.0

Package: ember-cli-htmlbars-inline-precompile

  • Specified: ^1.0.5

Package: ember-cli-inject-live-reload

  • Specified: ^1.10.2

Package: ember-cli-template-lint

  • Specified: ^1.0.0-beta.3

Package: ember-data

  • Specified: ^3.11.4

Package: ember-esri-loader

  • Specified: ^3.0.0

Package: ember-lodash

  • Specified: ^4.19.5

Package: ember-paper

  • Specified: ^1.0.0-beta.26

Package: ember-power-select

  • Specified: ^2.3.5

Package: ember-responsive

  • Specified: ^3.0.5

Package: ember-source

  • Specified: ^3.11.1

Package: eslint-plugin-ember

  • Specified: ^5.4.0

Package: qunit-dom

  • Specified: ^0.8.5

Package: sass

  • Specified: ^1.22.7

Package: esri-loader

  • Specified: ^2.10.0

Using this addon in an acceptance test causes "Assertion after the final `assert.async` was resolved" errors

There is a known issue about this w/ qunit v2 in ember apps (i.e. ember-cli-qunit 3.x), but for some reason, the suggested workarounds are not working in the one app I've seen this issue in. See ember-cli/ember-cli-qunit#162 (comment) Don't know if that's a sign of a fundamental issue w/ this addon, or that app, the way I tried to do the workaround, or a symptom of a broader problem.

Until that issue is resolved, we should try other workarounds (downgrade ember-cli-qunit version in that app), try the addon in other apps, and document the issue and any successful workarounds in the README.

Ember-cli 3.5 breaks this addon

Our current project uses ember-cli 3.5 and when trying to use the esriLoader service an exception is thrown on this loc. After adding a breakpoint and looking at the source files, it looks like the esri-loader.js files aren't added to the /public/assets folder when that line executes, so esriLoader is still undefined at that point.

It might be related to this issue but I don't know enough about the ember build process and the way this addon works to be sure.

This problem only occurs on 3.5. I created a fresh 3.4 app and everything seems to work there.

Would like to show use w/ 4.x and 3.x

First, should actually make sure it works w/ 4.x, but I'm pretty sure it will.

How to show both in the dummy app? Have both a 3x.html and 4x.html?

Open to ideas here.

Incompatible with ember-auto-import 2.x

We have recently tried updating to ember-auto-import 2.x, and found that this addon is not compatible with it.

In ember-auto-import 1.x, modules got injected into vendor.js or test-support.js. These files then later got rewritten by ember-esri-loader to replace require and define, and everything worked.

In ember-auto-import 2.x, modules are getting placed in external js files (chunk.*.js files), which are then loaded via <script> tags in index.html. This addon is failing to replace require and define in these chunk files, since it is hard-coded to only consider a few files (see

files: [
new RegExp(path.parse(outputPaths.app.js).name + '(.*js)'),
new RegExp(path.parse(outputPaths.vendor.js).name + '(.*js)'),
new RegExp(path.parse(outputPaths.tests.js).name + '(.*js)'),
'tests/index.html',
new RegExp(path.parse(outputPaths.testSupport.js.testSupport).name + '(.*js)')
],
).

One of the new chunk files, which is named /assets/chunk.app.[some-hash].js by default, attempts to capture require and define from the app (see https://github.com/ef4/ember-auto-import/blob/main/packages/ember-auto-import/ts/webpack.ts#L69-L79). This file is currently not getting rewritten by this addon, resulting in an error like Uncaught ReferenceError: require is not defined at runtime.

I was able to work around this problem by hacking the webpack configuration passed to ember-auto-import:

autoImport: {
  webpack: {
    output: {
      filename: 'my-app.chunk.[id].[chunkhash].js',
    },
  },
},

With this change, the file that captures require and define satisfies the regex at

new RegExp(path.parse(outputPaths.app.js).name + '(.*js)'),
, so it gets rewritten.

While this works, I think we could probably better support ember-auto-import 2.x in this addon. One simple option might be to expose an option that allows the user to identify more files that should be processd by this addon. For example, a user could include something like this in ember-cli-build.js:

'ember-esri-loader': {
  additionalFiles: [ /chunk\..*\.js/ ],
}

Breaks in Ember 3.25 (and perhaps earlier) apps

Somewhere between ember 3.16 and 3.25, something changed and it appears to cause the esri-loader script to be included in the files that we replace require() and define().

STR:

  • create a new 3.25 app
  • add ember-esri-loader
  • call loadModules()

You'll get the following error:

image

Digging into that you see that it fails on this line in esri-loader.js:

image

which should be

var errorHandler = window['require'].on('error', reject);

I also notice that yarn test:all fails on the release and canary scenarios, so that may be related, but it also failed on the 2.x scenario, so 🤷 :

------ RESULTS ------

Scenario ember-lts-2.16: FAIL
Command run: ember test
with env: {
  "EMBER_OPTIONAL_FEATURES": "{\"jquery-integration\":true}"
}
Scenario ember-lts-2.18: SUCCESS
Command run: ember test
with env: {
  "EMBER_OPTIONAL_FEATURES": "{\"jquery-integration\":true}"
}
Scenario ember-release: SUCCESS
Command run: ember test
Scenario ember-beta: FAIL
Command run: ember test
Scenario ember-canary: FAIL
Command run: ember test
Scenario ember-default: SUCCESS
Command run: ember test
Scenario ember-default-with-jquery: SUCCESS
Command run: ember test
with env: {
  "EMBER_OPTIONAL_FEATURES": "{\"jquery-integration\":true}"
}

3 scenarios failed
4 scenarios succeeded
7 scenarios run

Add option to defer script?

I've tested this, and I can't tell any difference when you add the defer to the script attribute when preloading, but it would be very easy to support passing that in as an option.

Hi amigos, can you help an Ember newby with a problem with ember-esri-loader ?

Problem: I´m getting espected layers but no stratified (one on top of next one).
probably cause dont know how to handle the template in Ember.

Details:
Using ember-cli: 2.11.1 node: 6.10.3 os: win32 x64

Using the lazy load in maps.js route

import Ember from 'ember';

export default Ember.Route.extend({
esriLoader: Ember.inject.service('esri-loader'),
init () {
this._super(...arguments);
const esriLoader = this.get('esriLoader');
esriLoader.load().catch(err => {
alert('entre al error de lazy load the JSAPI en init maps.js !');
});
}
});

Using a component named esri-map.js as follows

import Ember from 'ember';
import layout from '../templates/components/esri-map';

export default Ember.Component.extend({
layout,
esriLoader: Ember.inject.service('esri-loader'),

didInsertElement () {
this._super(...arguments);

  this.get('esriLoader').loadModules(['esri/Map', 'esri/views/MapView', 'esri/Graphic', 'esri/geometry/Point', 'esri/geometry/Polyline', 'esri/geometry/Polygon', 'esri/symbols/SimpleLineSymbol', 'esri/symbols/SimpleMarkerSymbol', 'esri/symbols/SimpleFillSymbol']).then(modules => {
  const [Map, MapView, Graphic, Point, Polyline, Polygon, SimpleLineSymbol, SimpleMarkerSymbol, SimpleFillSymbol] = modules;      
 
  var map = new Map({
    basemap: 'satellite'  
  });            
    var view = new MapView({
    center: [-80, 35],
    //container: 'app-container', //when using this container renders nothing
    container: 'viewDiv',   //when using this container renders spected layers but not in stratified mode
    map: map,
    zoom: 3,
 });    
  
  // Create a point graphic //
  var point = new Point({
    longitude: -49.97,
    latitude: 41.73
  });

  // Create a symbol for drawing the point
  var markerSymbol = new SimpleMarkerSymbol({
    color: [226, 119, 40],
    outline: { // autocasts as new SimpleLineSymbol()
      color: [255, 255, 255],
      width: 2
    }
  });

  // Create a graphic and add the geometry and symbol to it
  var pointGraphic = new Graphic({
    geometry: point,
    symbol: markerSymbol
  });
   // Create a polyline graphic       
    // Create a line geometry with the coordinates of the line
  var polyline = new Polyline({
    paths: [
        [-111.30, 52.68],
        [-98, 49.5],
        [-93.94, 29.89]
      ]
  });    
  // Create a simple line symbol for rendering the line in the view
  var lineSymbol = new SimpleLineSymbol({
    color: [226, 119, 40],  // RGB color values as an array
    width: 4
  });

  // Create a simple object containing useful information relating to the feature
  var lineAtt = {
    Name: 'Keystone Pipeline',  // The name of the pipeline
    Owner: 'TransCanada',  // The owner of the pipeline
    Length: '3,456 km'  // The length of the pipeline
  };

  // Create the graphic
  var polylineGraphic = new Graphic({
    geometry: polyline,   
    symbol: lineSymbol,   
    attributes: lineAtt,   
    popupTemplate: {
      title: "{Name}",
      content: [{
        type: "fields",
        fieldInfos: [{
          fieldName: "Name"
        }, {
          fieldName: "Owner"
        }, {
          fieldName: "Length"
        }]
      }]
  }
});

//Create a polygon graphic
  // Create a polygon geometry
  var polygon = new Polygon({
    rings: [
      [-64.78, 32.3],
      [-66.07, 18.45],
      [-80.21, 25.78],
      [-64.78, 32.3]
    ]
  });

  // Create a symbol for rendering the graphic
  var fillSymbol = new SimpleFillSymbol({
    color: [227, 139, 79, 0.8],
    outline: { // autocasts as new SimpleLineSymbol()
      color: [255, 255, 255],
      width: 1
    }
  });

  // Add the geometry and symbol to a new graphic
  var polygonGraphic = new Graphic({
    geometry: polygon,
    symbol: fillSymbol
  });

  // Add the graphics to the view's graphics layer
  view.graphics.addMany([pointGraphic, polylineGraphic, polygonGraphic]);            

})
}
});

my style file App.css contains

@import url('https://js.arcgis.com/3.21/esri/css/esri.css');

body, #viewDiv {
padding: 0;
margin: 0;
height: 140%;
width: 100%;
}

Using a template esri-map.hbs

{{view}}

Did I miss something ?
Hope you can see a solution
Thanks in advance
Enrique Gonzalez

An app's production build breaks if source maps are enabled.

When I run ember build -e=production on an app that has ember-esri-loader installed, I get the following error:

Error: ENOENT: no such file or directory, open 'project-path/esri-loader-test/tmp/uglify_writer-input_base_path-GKD3EADg.tmp/assets/dist/esri-loader.min.js.map'
    at Object.fs.openSync (fs.js:584:18)
    at Object.fs.readFileSync (fs.js:491:33)
    at UglifyWriter.processFile (project-path/esri-loader-test/node_modules/broccoli-uglify-sourcemap/index.js:101:41)
    at project-path/esri-loader-test/node_modules/broccoli-uglify-sourcemap/index.js:65:16
    at Array.forEach (native)
    at project-path/esri-loader-test/node_modules/broccoli-uglify-sourcemap/index.js:55:25
    at Array.forEach (native)
    at UglifyWriter.build (project-path/esri-loader-test/node_modules/broccoli-uglify-sourcemap/index.js:54:19)
    at project-path/esri-loader-test/node_modules/broccoli-plugin/read_compat.js:93:34
    at tryCatch (project-path/esri-loader-test/node_modules/rsvp/dist/rsvp.js:525:12)

The broccoli plugin was instantiated at:
    at Fingerprint.Plugin (project-path/esri-loader-test/node_modules/broccoli-plugin/index.js:7:31)
    at Fingerprint.Filter [as constructor] (project-path/esri-loader-test/node_modules/broccoli-filter/index.js:34:10)
    at new Fingerprint (project-path/esri-loader-test/node_modules/broccoli-asset-rev/lib/fingerprint.js:21:10)
    at Fingerprint (project-path/esri-loader-test/node_modules/broccoli-asset-rev/lib/fingerprint.js:16:12)
    at new AssetRev (project-path/esri-loader-test/node_modules/broccoli-asset-rev/lib/asset-rev.js:31:25)
    at AssetRev (project-path/esri-loader-test/node_modules/broccoli-asset-rev/lib/asset-rev.js:7:12)
    at Class.postprocessTree (project-path/esri-loader-test/node_modules/broccoli-asset-rev/index.js:31:40)
    at projectOrAddon.addons.reduce (project-path/esri-loader-test/node_modules/ember-cli/lib/utilities/addon-process-tree.js:6:25)
    at Array.reduce (native)
    at addonProcessTree (project-path/esri-loader-test/node_modules/ember-cli/lib/utilities/addon-process-tree.js:4:32)

Thought it might have something to do with this issue: emberjs/ember.js#15720, but I updated to my app to ember v2.16.0 but still get the error.

Here's a sample app: https://github.com/ssylvia/ember-esri-loader-sourcemap-build-fail-demo.

Production builds of apps that use this addon fail due to integrity check errors

Failed to find a valid digest in the 'integrity' attribute for resource 'http://localhost:4200/assets/vendor-3c22350e6572efd13856e2c5294f034c.js' with computed SHA-256 integrity '3oRzJNp9Pj3PyXRjq1CdtDesYjbnnWxPBvpyZkYCou4='. The resource has been blocked.

This does not happen in the dummy app, only in apps that are npm linked.

I wonder if this is related to #35 although, in this case, the build doesn't break, it's just that the built app won't run due to the resource being blocked by the browser.

Update esri-loader dependency version notation

At the moment the esri-loader dependency is defined like this: "esri-loader": "~2.5.0".

How about changing that to "esri-loader": "^2.5.0"? That way we wouldn't have to manually keep these repos in sync.

How to use w/ fastboot?

Hopefully a benefit of this approach over that in ember-cli-amd would be that we can use it w/ fastboot.

get ember-try working again

I have no idea what the fuck happened in #76 but the whole stack of cards came crashing down.

I could not replicate the template lint errors locally.

I can't run ember-try locally. I can't even really run ember t locally unless I supply the -s parameter, otherwise it "fails" w/ this error at the command line:

➜  ember-esri-loader git:(f/updating-js-api) ember t
Environment: test
cleaning up...
Built project successfully. Stored in "/Users/tom6947/code/ember-esri-loader/tmp/class-tests_dist-E1MO9gxx.tmp".
ok 1 Firefox 68.0 - [1 ms] - ESLint | addon: addon/mixins/esri-module-cache.js
ok 2 Firefox 68.0 - [1 ms] - ESLint | addon: addon/services/esri-loader.js
ok 3 Firefox 68.0 - [0 ms] - ESLint | app: app/services/esri-loader.js
ok 4 Firefox 68.0 - [203 ms] - Acceptance | index: visiting /
not ok 5 Firefox - [undefined ms] - error
    ---
        message: >
            Error: Browser exited unexpectedly
            Error while executing test: Acceptance | map: visiting /map
            Non-zero exit code: 1
            
        Log: |
            { type: 'error', text: 'Error: Browser exited unexpectedly' }
            { type: 'error',
              text: 'Error while executing test: Acceptance | map: visiting /map' }
            { type: 'error', text: 'Non-zero exit code: 1' }
    ...

1..5
# tests 5
# pass  4
# skip  0
# fail  1
Testem finished with non-zero exit code. Tests failed.

Thing is, the tests really pass:

image

It's like the command lost the connection to FireFox.

Here's another riddle - why are tests running in FF locally anyway?

yarn run lint:hbs and ember t -s both pass for me locally, so 🤷‍♂

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.