Skip to content
This repository has been archived by the owner on Jan 19, 2024. It is now read-only.

Full path file name to worker.js causing error in output bundle #22

Closed
green3g opened this issue Aug 24, 2018 · 2 comments
Closed

Full path file name to worker.js causing error in output bundle #22

green3g opened this issue Aug 24, 2018 · 2 comments

Comments

@green3g
Copy link
Contributor

green3g commented Aug 24, 2018

Description

I'd like to open up a discussion on finding a solution to the question mentioned here:
https://stackoverflow.com/questions/51986624/webpack-babel-loader-outputting-full-c-drive-urls-in-bundles/52007420#52007420

Output bundles contain complete file path information (including username - if project is in user director).

This also causes a regular error with the workers.js file:

VM126171:1 Access to XMLHttpRequest at 'file:///C:/Users/<username>/web/apps/datafi/node_modules/arcgis-js-api/core/workers/worker.js' from origin 'http://lvh.me:9000' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

Expected Behavior

I don't believe that this should be happening. Its a potential security/privacy issue. File paths should be referenced via their node_module package.

Actual Behavior

File paths are getting included like this:

        "C:/Users/<username>/web/dl2-cia-wsb/node_modules/babel-loader/lib/index.js??ref--6-0!C:/Users/<username>/web/dl2-cia-wsb/src/components/cia-open-project/cia-open-project.stache": 1670,

Possible Fix

First we should determine whether or not this is being caused by the dojo webpack/arcgis webpack plugin.

Steps to Reproduce

All builds seem to have this output.

Context

Its slightly disconcerting that my username gets put in public facing javascript files.

Your Environment

  • Version used: 4.8.x
  • Operating System and version (desktop or mobile): Windows 7
@green3g
Copy link
Contributor Author

green3g commented Nov 5, 2018

Here's a basic example that I can reliably produce this error. See the webpack/packages config in this issue:

#30

What's happening here is webpack is splitting the code up into different bundles because the import('path'); is a dynamic import that may or not be used in this bundle.

The use case is my app can load the default esri/Map or it may conditionally load the esri/WebMap class in place and not need to load both. Same thing for esri/views/SceneView vs esri/views/MapView.

const layerlist = () => import('esri/widgets/LayerList').then((m) => m.default);
const map = () => import('esri/Map').then((m) => m.default);
const view = () => import('esri/views/MapView').then((m) => m.default);

map().then((Map) => {
    view().then((View) => {
        const map = new Map({
            layerlist: 'streets-vector',
        });

        const el = document.createElement('div');
        document.body.appendChild(el);
        const view = new View({
            map,
            container: el,
        });

        layerlist().then((LayerList) => {
            view.ui.add(new LayerList({view}));
        });
    });
});

@green3g green3g changed the title Investigate issue with full file path names getting into output bundles Full path file name to worker.js causing error in output bundle Nov 8, 2018
@green3g
Copy link
Contributor Author

green3g commented Nov 15, 2018

Closing as we've identified dojo-plugin as the source of the full file path issue.

OpenNTF/dojo-webpack-plugin#185

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant