Unable to leverage `allowSourceOverwrites` option? #629

Closed
cbaxter opened this Issue Feb 18, 2014 · 12 comments

Comments

Projects
None yet
9 participants
@cbaxter

cbaxter commented Feb 18, 2014

This is likely a misunderstanding on my part regarding the new allowSourceOverwrites option introduced in Issue #479.

Command:

r.js.cmd -o <path>\build.js dir=<path> appDir=<path>\js

Configuration:

({
    baseUrl: '.',
    keepBuildDir: true,
    allowSourceOverwrites: true,
    mainConfigFile: './js/main.js',
    paths: {
        ...
    },
    modules: [{
            ...
    ]
})

Resulting in the error

Module ID 'main' has a source path that is same as output path: <path>/main.js. Stopping, config is malformed.

The error originates from r.js v2.1.11 @ line 25999 where the build path is checked against the sourcePath. With allowSourceOverwrites being true should this not be allowed? I am using the build in the same scenario as described in #479 where my source is build output and I would prefer to overwrite the source rather than do an extra copy.

@jrburke

This comment has been minimized.

Show comment
Hide comment
@jrburke

jrburke Feb 19, 2014

Member

Looks like I was assuming the fix for #479 was not a direct source directory overwrite, but just in the same area. Did this work with r.js 2.1.6?

Member

jrburke commented Feb 19, 2014

Looks like I was assuming the fix for #479 was not a direct source directory overwrite, but just in the same area. Did this work with r.js 2.1.6?

@cbaxter

This comment has been minimized.

Show comment
Hide comment
@cbaxter

cbaxter Feb 19, 2014

@jrburke I was setting the build process for a new project over the weekend and that was the first time I had attempted to overwrite the source completely (so I have not tried 2.1.6). The build process I am using takes a clean copy of the uncompressed files for versioning (includes other content as well). Once moved to a versioned content folder, I then run the optimizer on the JavaScript files to minify/bundle where required so an extra copy was being performed. When I saw the 2.1.11 release a day later I had thought the new allowSourceOverwrites may allow me to avoid the extra copy step while maintaining the current build process.

I can always do a copy of all non JavaScript content to the versioned content folder, and then run the optimizer to copy over the JavaScript files to the versioned folder to avoid the extra copy, so not a huge deal if I misunderstood the purpose of the new option.

I can try running the build using r.js v2.1.6 to confirm previous behavior if there is value in doing so?

cbaxter commented Feb 19, 2014

@jrburke I was setting the build process for a new project over the weekend and that was the first time I had attempted to overwrite the source completely (so I have not tried 2.1.6). The build process I am using takes a clean copy of the uncompressed files for versioning (includes other content as well). Once moved to a versioned content folder, I then run the optimizer on the JavaScript files to minify/bundle where required so an extra copy was being performed. When I saw the 2.1.11 release a day later I had thought the new allowSourceOverwrites may allow me to avoid the extra copy step while maintaining the current build process.

I can always do a copy of all non JavaScript content to the versioned content folder, and then run the optimizer to copy over the JavaScript files to the versioned folder to avoid the extra copy, so not a huge deal if I misunderstood the purpose of the new option.

I can try running the build using r.js v2.1.6 to confirm previous behavior if there is value in doing so?

@jrburke jrburke added this to the 2.1.12 milestone Feb 24, 2014

@jrburke

This comment has been minimized.

Show comment
Hide comment
@jrburke

jrburke Feb 24, 2014

Member

It looks like the allowSourceOverwrites needs to disable some more checks. I expect what you want to do with it would not have worked with 2.1.6 though. I'll put this into the 2.1.12 bucket for more research on what would be needed to allow it. If it does not seem too hazardous, I'll get it fixed up.

Member

jrburke commented Feb 24, 2014

It looks like the allowSourceOverwrites needs to disable some more checks. I expect what you want to do with it would not have worked with 2.1.6 though. I'll put this into the 2.1.12 bucket for more research on what would be needed to allow it. If it does not seem too hazardous, I'll get it fixed up.

@jrburke jrburke modified the milestones: 2.2.0, 2.1.12 May 22, 2014

@dbashford

This comment has been minimized.

Show comment
Hide comment
@dbashford

dbashford Jun 7, 2014

Getting this same error. Can't seem to optimize projects that have a modules config.

{
  "allowSourceOverwrites": true,
  "baseUrl": "/path/to/public/javascripts",
  "wrap": true,
  "mainConfigFile": "/path/to/public/javascripts/main.js",
  "dir": "public/javascripts",
  "modules": [
    {
      "name": "main",
      "include": [
        "almond"
      ]
    }
  ],
  "keepBuildDir": true
}
[Error: Module ID 'main' has a source path that is same as output path: /path/to/public/javascripts/main.js. Stopping, config is malformed.]

Getting this same error. Can't seem to optimize projects that have a modules config.

{
  "allowSourceOverwrites": true,
  "baseUrl": "/path/to/public/javascripts",
  "wrap": true,
  "mainConfigFile": "/path/to/public/javascripts/main.js",
  "dir": "public/javascripts",
  "modules": [
    {
      "name": "main",
      "include": [
        "almond"
      ]
    }
  ],
  "keepBuildDir": true
}
[Error: Module ID 'main' has a source path that is same as output path: /path/to/public/javascripts/main.js. Stopping, config is malformed.]

@dbashford dbashford referenced this issue in dbashford/mimosa-require Jun 7, 2014

Open

Upgrade to latest require #38

@kieran-bamforth

This comment has been minimized.

Show comment
Hide comment
@kieran-bamforth

kieran-bamforth Jun 10, 2014

I too am getting the same issue (Unless I'm failing to understand how this works):

    mainConfigFile: './main.js',
    allowSourceOverwrites: true,
    keepBuildDir: true,
    appDir: '../.dist-tmp',
    baseUrl: 'js',
    dir: '../.dist-tmp',
    modules: [
        {
            name: 'main'
        },
        {
            name: 'page/index'
        },
        {
            name: 'page/video'
        },
    ]
})

Error: Error: Module ID 'main' has a source path that is same as output path: *path* Stopping, config is malformed.
    at *path*:26000:39

I too am getting the same issue (Unless I'm failing to understand how this works):

    mainConfigFile: './main.js',
    allowSourceOverwrites: true,
    keepBuildDir: true,
    appDir: '../.dist-tmp',
    baseUrl: 'js',
    dir: '../.dist-tmp',
    modules: [
        {
            name: 'main'
        },
        {
            name: 'page/index'
        },
        {
            name: 'page/video'
        },
    ]
})

Error: Error: Module ID 'main' has a source path that is same as output path: *path* Stopping, config is malformed.
    at *path*:26000:39
@eclifford

This comment has been minimized.

Show comment
Hide comment
@eclifford

eclifford Jun 13, 2014

I am having this same issue. I thought allowSourceOverwrites would fix this but it is not. Back to 2.1.6 for now :).

I am having this same issue. I thought allowSourceOverwrites would fix this but it is not. Back to 2.1.6 for now :).

@atrauzzi

This comment has been minimized.

Show comment
Hide comment
@atrauzzi

atrauzzi Aug 16, 2014

Just encountered this today. Not sure what information I would need to provide to be of any help.

Just encountered this today. Not sure what information I would need to provide to be of any help.

@dbashford

This comment has been minimized.

Show comment
Hide comment
@dbashford

dbashford Aug 31, 2014

Still stuck here. And just recently need some other fixes that I can't upgrade to get.

Still stuck here. And just recently need some other fixes that I can't upgrade to get.

@DrSammyD

This comment has been minimized.

Show comment
Hide comment
@DrSammyD

DrSammyD Dec 4, 2014

+1 to this issue

DrSammyD commented Dec 4, 2014

+1 to this issue

@enzeart

This comment has been minimized.

Show comment
Hide comment
@enzeart

enzeart Dec 16, 2014

+1 as well.

Here is my expectation of how this configuration should work, correct me if I'm wrong.

Copy everything in 'appDir' to 'dir', iterate through 'modules', optimize each configured module, and place them in the corresponding location in 'dir'.

It seems to be trying to place the output file back at the original location. When it fails it always complains about the file existing at the original path and not the one at the expected output path in the build directory.

enzeart commented Dec 16, 2014

+1 as well.

Here is my expectation of how this configuration should work, correct me if I'm wrong.

Copy everything in 'appDir' to 'dir', iterate through 'modules', optimize each configured module, and place them in the corresponding location in 'dir'.

It seems to be trying to place the output file back at the original location. When it fails it always complains about the file existing at the original path and not the one at the expected output path in the build directory.

@enzeart

This comment has been minimized.

Show comment
Hide comment
@enzeart

enzeart Dec 23, 2014

FInally got something working. Kinda stumbled into though so not sure what exactly fixed what.

My config:

appDir: 'WebContent/',
baseUrl: 'js',
dir: 'WebContent/js/build/',
mainConfigFile: 'WebContent/js/main.js',
modules: [
  {
      name: 'main'
  },
  {
      name: 'app'
  }
]

My directory layout:
image

This is for anyone that was having general issues using the module config.

enzeart commented Dec 23, 2014

FInally got something working. Kinda stumbled into though so not sure what exactly fixed what.

My config:

appDir: 'WebContent/',
baseUrl: 'js',
dir: 'WebContent/js/build/',
mainConfigFile: 'WebContent/js/main.js',
modules: [
  {
      name: 'main'
  },
  {
      name: 'app'
  }
]

My directory layout:
image

This is for anyone that was having general issues using the module config.

@peol

This comment has been minimized.

Show comment
Hide comment
@peol

peol May 25, 2015

@jrburke : I can confirm that changing if (module._buildPath === module._sourcePath) { to if (module._buildPath === module._sourcePath && !config.allowSourceOverwrites) { fixes this specific issue and I got a working build folder.

peol commented May 25, 2015

@jrburke : I can confirm that changing if (module._buildPath === module._sourcePath) { to if (module._buildPath === module._sourcePath && !config.allowSourceOverwrites) { fixes this specific issue and I got a working build folder.

@jrburke jrburke modified the milestones: 2.1.18, 2.2.0 May 26, 2015

@jrburke jrburke closed this in 9bfe828 May 28, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment