# Can-util/import || steal.import - 404 when build

**URL:** <https://forums.bitovi.com/t/can-util-import-steal-import-404-when-build/958>\
**Category:** StealJS\
**Created:** [September 7, 2018, 8:35am UTC](https://forums.bitovi.com/t/can-util-import-steal-import-404-when-build/958 "2018-09-07T08:35:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeroencornelissen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/jeroencornelissen/32/180_2.png) [@jeroencornelissen](https://forums.bitovi.com/u/jeroencornelissen)\
**Post date:** [September 7, 2018, 8:35am UTC](https://forums.bitovi.com/t/can-util-import-steal-import-404-when-build/958/1 "2018-09-07T08:35:28Z")

</div>

I’m importing some config from a js file like this:

```auto
import importModule from 'can-util/js/import/import';
//...

importModule(this.config.path).then(module => {
 console.log(module.default)
})

```

`config.path` looks like this `~/config/dashboard/page-one`

This works but if I switch from **page-one** to **page-two** and back to **page-one**. It seems that `page-one` is cached and I don’t see a request, but the `then` resolves with `page-two` data.

I’ve solve it with adding a cache-buster like this:

```auto
importModule(this.config.path + '.js?c=' + new Date().getTime() ).then(module => {
 console.log(module.default)
})

```

Is this normal? Or a bug in `importModule`?

Edit: `window.steal.import()` behaves the same.

---

<div class="post-metadata">

**Author:** ![jeroencornelissen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/jeroencornelissen/32/180_2.png) [@jeroencornelissen](https://forums.bitovi.com/u/jeroencornelissen)\
**Post date:** [September 7, 2018, 12:05pm UTC](https://forums.bitovi.com/t/can-util-import-steal-import-404-when-build/958/2 "2018-09-07T12:05:41Z")

</div>

So this doesn’t work when it’s build with Steal.

My `package.json` looks like this:

```auto
{
  "name": "project-name",
  "version": "1.0.0",
  "main": "main.js",
  "files": [
    "."
  ],
  "steal": {
    "main": "main.js",
    "plugins": [
      "steal-css",
      "steal-less",
      "steal-stache"
    ],
    "lessOptions": {
      "relativeUrls": false
    },
    "bundle": [
      "~/config/dashboard/page-one",
      "~/config/dashboard/page-two"
    ]
  }
}

```

This is my folder structure the build produces:

```auto
📁 dist
    📁 project-name
        📁 config
            📁 dashboard
                📄 page-one.js
                📄 page-two.js
            //some shared files
        //some shared files
    📄 main.js
    //some shared files

```

I get a 404 because my path looks like this: `~/config/dashboard/page-one` but that file doesn’t exist in the build.  
The build generated / **project-name** /config/dashboard/page-one.

And if I change my path to `project-name/config/dashboard/page-one`, Steal strips off the **project-name** and thus loading a non exisiting file.

---

<div class="post-metadata">

**Author:** ![justinbmeyer](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/justinbmeyer/32/179_2.png) [@justinbmeyer](https://forums.bitovi.com/u/justinbmeyer)\
**Post date:** [September 7, 2018, 8:14pm UTC](https://forums.bitovi.com/t/can-util-import-steal-import-404-when-build/958/3 "2018-09-07T20:14:25Z")

</div>

Which version of `steal` are you using? Can you create a small example that we can look at?

---

<div class="post-metadata">

**Author:** ![jeroencornelissen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/jeroencornelissen/32/180_2.png) [@jeroencornelissen](https://forums.bitovi.com/u/jeroencornelissen)\
**Post date:** [September 8, 2018, 7:00am UTC](https://forums.bitovi.com/t/can-util-import-steal-import-404-when-build/958/4 "2018-09-08T07:00:42Z")

</div>

@justinbmeyer latest `steal@2.1.2` and `steal-tools@2.0.5`

Here is a simplified demo. You’ll see that `index.dev.html` works but `index.prod.html` not.

> **[jeroencornelissen/steal-test](https://github.com/jeroencornelissen/steal-test)**
>
> https://forums.donejs.com/t/can-util-import-steal-import-404-when-build/958/4 - jeroencornelissen/steal-test

---

<div class="post-metadata">

**Author:** ![matthewp](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/matthewp/32/77_2.png) [@matthewp](https://forums.bitovi.com/u/matthewp)\
**Post date:** [September 10, 2018, 8:32pm UTC](https://forums.bitovi.com/t/can-util-import-steal-import-404-when-build/958/5 "2018-09-10T20:32:48Z")

</div>

There’s a bug in the app’s code. page-one is defined as:

```auto
import BaseConfig from "~/config/dashboard/base";

export default Object.assign(BaseConfig, { name: "Page One" });

```

and page-two as:

```auto
import BaseConfig from "~/config/dashboard/base";

export default Object.assign(BaseConfig, { name: "Page Two" });

```

each one mutates the `BaseConfig` object. After the second one loads the object won’t be changed again. So the problem is that both modules export the same object.

I think you probably want to create a new object, you can use:

```auto
import BaseConfig from "~/config/dashboard/base";

export default Object.assign({}, BaseConfig, { name: "Page Two" });

```

In each of them. Notice that the first argument to `Object.assign` is a new object `{}`.

---

<div class="post-metadata">

**Author:** ![jeroencornelissen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.bitovi.com/jeroencornelissen/32/180_2.png) [@jeroencornelissen](https://forums.bitovi.com/u/jeroencornelissen)\
**Post date:** [September 11, 2018, 7:26am UTC](https://forums.bitovi.com/t/can-util-import-steal-import-404-when-build/958/6 "2018-09-11T07:26:00Z")

</div>

Thanks @matthewp!!!

Didn’t realised I was mutating the Base object and didn’t know you could pass more then 2 objects to `Object.assign`. 👍
