stealjs / steal

Gets JavaScript
https://stealjs.com
MIT License
1.37k stars 522 forks source link

stealTools.build with alternate main (not honouring existing package.json settings) #1272

Open emergesource opened 7 years ago

emergesource commented 7 years ago

How often can you reproduce it?

Description:

I'm trying to provide multiple entry points to my application to facilitate vue ssr. If I try to override the main option as a config param for stealTools.build() it does not seem to inherit the existing settings found in package.json (plugins, src paths etc)

Steps to reproduce:

Run build() with initial config from package.json & overide the main entry.

stealTools.build({ config: __dirname + "/package.json!npm", main: ["entry-server.js", "entry-client.js"] }, ...

Expected results:

Would expect all package.json settings to be honoured, and both entry point bundles would be created.

Actual results:

Path & plugin errors as if the existing config options are ignored.

Environment:

Software Version
Steal version 1.5.13
Steal-tools version 1.8.4
node -v v6.11.3
npm -v 3.10.10
Browser N/A
Operating system Linux
matthewp commented 7 years ago

Is there an example of a setting that is not being honored?

emergesource commented 7 years ago
Error: Error loading "entry-server" at file:/home/colin/devel/nazca-client-admin-vue/entry-server.js
Could not load 'entry-server'
Is this an NPM module not saved in your package.json?
    at file:/home/colin/devel/nazca-client-admin-vue/node_modules/steal/ext/npm-extension.js:351:11
    at tryCatchReject (/home/colin/devel/nazca-client-admin-vue/node_modules/steal/src/loader/loader.js:1183:30)
    at runContinuation1 (/home/colin/devel/nazca-client-admin-vue/node_modules/steal/src/loader/loader.js:1142:4)
    at Rejected.when (/home/colin/devel/nazca-client-admin-vue/node_modules/steal/src/loader/loader.js:963:4)
    at Pending.run (/home/colin/devel/nazca-client-admin-vue/node_modules/steal/src/loader/loader.js:821:13)
    at Scheduler._drain (/home/colin/devel/nazca-client-admin-vue/node_modules/steal/src/loader/loader.js:97:19)
    at Scheduler.drain (/home/colin/devel/nazca-client-admin-vue/node_modules/steal/src/loader/loader.js:62:9)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)
matthewp commented 7 years ago

Is entry-server a npm package or is it a javascript file?

emergesource commented 7 years ago
{
  "name": "nazca-client-admin-vue",
  "version": "1.0.0",
  "description": "",
  "main": "entry-client.js",
  "scripts": {
    "start": "node server.js",
    "test": "echo \"Error: no test specified\" && exit 1",
    "build": "node build --production",
    "build:server": "webpack --config ./build/webpack.server.config.js --progress --hide-modules",
    "build:client": "webpack --config ./build/webpack.client.config.js --progress --hide-modules",
    "build-debug": "node build --debug",
    "dev-bundle": "steal-tools bundle --dev"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "babel-core": "^6.26.0",
    "babel-loader": "^7.1.2",
    "babel-plugin-transform-runtime": "^6.23.0",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-stage-0": "^6.24.1",
    "babel-runtime": "^6.26.0",
    "css-loader": "^0.28.7",
    "express": "^4.15.4",
    "http-proxy-middleware": "^0.17.4",
    "jquery": "^3.2.1",
    "less-loader": "^4.0.5",
    "lodash": "^4.17.4",
    "morgan": "^1.8.2",
    "nazca-client-core-misc": "^1.0.2",
    "steal": "^1.5.13",
    "steal-bundle-manifest": "^1.0.4",
    "steal-less": "^1.2.0",
    "steal-vue": "0.0.6",
    "superagent": "^3.6.0",
    "vue": "^2.4.3",
    "vue-loader": "^13.0.4",
    "vue-router": "^2.7.0",
    "vue-server-renderer": "^2.4.2",
    "vue-template-compiler": "^2.4.2",
    "vuex": "^2.4.0",
    "webpack": "^3.5.6"
  },
  "devDependencies": {
    "steal-tools": "^1.8.4"
  },
  "browser": {
    "superagent": "superagent/superagent"
  },
  "steal": {
    "directories": {
      "lib": "src"
    },
    "plugins": [
      "steal-vue",
      "steal-css",
      "steal-less"
    ],
    "map": {
      "vue": "vue/dist/vue.common"
    }
  }
}
emergesource commented 7 years ago
const buildPromiseClient = stealTools.build({
        config: __dirname + "/package.json!npm",
        main: ["entry-server", "entry-client"]
}, {
                // BuildOptions
                bundleAssets: true,     // copy referenced assets into 'dist'-folder
                //bundleSteal: true,    // commented-out: not compatible with done-autorender? insert steal-library into main-bundle
                //bundleManifest: true, // generate http2-push-manifest for server-side-preload
                // ExportObject
                debug: true,    // enable debug-messages
                verbose: true,  // enable logging
                // ExportOutput
                dest: __dirname + "/dist/" + PROMO_DATE,
                // TransformOptions
                minify: (isProduction),
                cleanCSSOptions: {
                        rebase: false   // fix: for donejs-1.0, set to false to resolve image-paths being broken in (minified) prod-mode. as-per bitovi-kevin
                }
        }).then(
        // done
        function (buildResult) {
                //console.log({"buildPromise.done.buildResult": buildResult});
        },
        // fail
        function (buildResult) {
                console.log(buildResult);
                // exit 'failure'-code
                process.exit(1);
        }
);
emergesource commented 7 years ago

It's a js file

emergesource commented 7 years ago

It's not reading from the src folder as config'd in package.json. And if I fix the paths manually, the steal-vue doesn't seem to be working either...

Error: Error loading "nazca-client-admin-vue@1.0.0#../components/NazcaLogin.vue!steal-vue@0.0.6#steal-vue" at file:/home/colin/devel/nazca-client-admin-vue/components/NazcaLogin.vue
Error loading "nazca-client-admin-vue@1.0.0#../components/NazcaLogin.vue!steal-vue@0.0.6#steal-vue" from "src/entry-server" at file:/home/colin/devel/nazca-client-admin-vue/src/entry-server.js
Error loading "steal-vue@0.0.6#steal-vue/index" at file:/home/colin/devel/nazca-client-admin-vue/node_modules/steal-vue/steal-vue/index.js
Could not load 'steal-vue@0.0.6#steal-vue/index'
Is this an NPM module not saved in your package.json?
    at file:/home/colin/devel/nazca-client-admin-vue/node_modules/steal/ext/npm-extension.js:351:11
    at tryCatchReject (/home/colin/devel/nazca-client-admin-vue/node_modules/steal/src/loader/loader.js:1183:30)
    at runContinuation1 (/home/colin/devel/nazca-client-admin-vue/node_modules/steal/src/loader/loader.js:1142:4)
    at Rejected.when (/home/colin/devel/nazca-client-admin-vue/node_modules/steal/src/loader/loader.js:963:4)
    at Pending.run (/home/colin/devel/nazca-client-admin-vue/node_modules/steal/src/loader/loader.js:821:13)
    at Scheduler._drain (/home/colin/devel/nazca-client-admin-vue/node_modules/steal/src/loader/loader.js:97:19)
    at Scheduler.drain (/home/colin/devel/nazca-client-admin-vue/node_modules/steal/src/loader/loader.js:62:9)
    at _combinedTickCallback (internal/process/next_tick.js:73:7)
    at process._tickCallback (internal/process/next_tick.js:104:9)
matthewp commented 7 years ago

if you change your mains to : ["nazca-client-admin-vue/entry-server", "nazca-client-admin-vue/entry-client"] does it change anything?

emergesource commented 7 years ago

Booya! I think that worked.

matthewp commented 7 years ago

:( sorry you had to do that.

matthewp commented 7 years ago

Might be something we can prevent from having to do.

emergesource commented 7 years ago

Would be nice because if we change the project name or something in the future, we have to remember to change that as well.

Get's me going though, thanks!

matthewp commented 7 years ago

does this work? main: ["~/entry-server", "~/entry-client"]

emergesource commented 7 years ago

That works. is that supposed to be relative to what we defined in directories/lib ?

matthewp commented 7 years ago

Yep!