jmm / pathmodify

In a nutshell, rewrite (AKA alias, map) `require()` IDs / paths / directories to different values in browserify.
MIT License
27 stars 1 forks source link

Unable to find babel plugin after path modify #12

Open udalrich opened 7 years ago

udalrich commented 7 years ago

I am running babelify with browserify in gulp by the following code:

return browserify(
    {
        // Only need initial file, browserify finds the deps
        entries: [bundlePath + '/main.jsx'],
        debug: true,
        cache: {},
        packageCache: {},
        fullPaths: true,
        paths: [ __dirname + '/node_modules', __dirname ]
    })
    .plugin(pathmodify(), {
        mods: [
            pathmodify.mod.dir('foo', __dirname + '/../target/commonui/assets/javascripts'),
        ]})
    .transform("babelify", {
        presets: ["es2015", "react"],
        plugins: ["transform-object-rest-spread"]
    });

Previously, the files were under the current directory and I could successfully load them by import Stuff from './stuff.jsx'

I moved them to support sharing with a related project, so now I need a complicated path to them.

When I run gulp browserify, I get this output.

looking for main.jsx in  app/assets/javascripts which is /Users/tda0106/projects/project/dev/components/ui/ca/web/ui/app/assets/javascripts
[12:42:55] Using gulpfile ~/projects/project/dev/components/ui/ca/web/ui/gulpfile.js
(node:32497) DeprecationWarning: Deprecated: pathmodify: Don't call the export as a factory. The export is now the plugin function.
[12:42:55] Starting 'browserify'...
[12:42:55] Finished 'browserify' after 1.88 ms
Error runing browserify Unknown plugin "transform-object-rest-spread" specified in "base" at 0, attempted to resolve relative to "/Users/tda0106/projects/project/dev/components/ui/ca/web/target/commonui/assets/javascripts/utils" while parsing file: /Users/tda0106/projects/project/dev/components/ui/ca/web/target/commonui/assets/javascripts/utils/FetchUtils.jsx undefined

If I remove the paths from browserify, I get the same result. (That is left over from attempting to use remapify.)

If I remove the plugins line, I get an error that the plugin would fix, and an error that it cannot resolve the es2015 preset referencing the same directory as above.