-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Offer unpacked code from package.json #508
Conversation
Also, adjust configuration for compatibility with unpacked audio, render, and storage modules. - Update `package.json` to point to `src/index.js` as the main script - Move runtime dependencies from `devDependencies` to `dependencies` - Remove `dist/node/*` build output & simplify webpack config file - Tell Travis CI to target Node.js 6 instead of 4 since published code will now use ES6 features
@@ -9,13 +9,28 @@ var base = { | |||
host: '0.0.0.0', | |||
port: process.env.PORT || 8073 | |||
}, | |||
devtool: 'source-map', | |||
devtool: 'cheap-module-source-map', |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
webpack.config.js
Outdated
], | ||
resolve: { | ||
symlinks: false | ||
} |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
webpack.config.js
Outdated
rules: [ | ||
{ | ||
// allow ES2015 in any *.js file under .../scratch-*/src/... | ||
test: /[\\/]+scratch-[^\\/]+[\\/]+src[\\/]+.+\.js$/, |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Conflicts: package.json
This fixes two problems: - module rules were not being correctly passed to webpack - now that `resolve: { symlinks: false }` has been added to the webpack config, webpack and Node disagree on the path to a module accessed through `npm link`. This means that passing `require.resolve`'s result to webpack is no longer guaranteed to work for a module `test`. Instead we now use `path.resolve` which will match webpack's idea of the path.
Turning off symlink resolution in webpack was a quick fix but complicates things by making webpack act less like Node.js than it otherwise would. This change restores default symlink resolution behavior for webpack, which matches Node. In order to make Babel work with `npm link`ed modules even when symlink resolution is enabled, the include paths for `babel-loader` are now being run through `fs.realpathSync`.
5179f30
to
a4a0d60
Compare
I dug a bit further into Background info: when Node.js In webpack, this behavior can be configured using the
This difference matters if, for example, we use Unfortunately, things go wrong when webpack tries to load a plugin or preset. It appears that webpack looks for its plugins and presets only in parent directories of the file currently being processed. That is, if we're currently processing Because of this, enabling I scoured the web for solutions more elegant than what I describe below; I didn't find any. Some people recommend adding There are two solutions I've found; they're described below and each is represented as a commit in this PR. Please don't let the order of the commits affect your opinion: the order reflects when I figured out each technique, not necessarily a preference. I do have a preference but I'd like your unbiased input. :) Option 1: Use
Option 2: Use absolute paths to load webpack plugins & presets (let
Thoughts? Preferences? |
Closing this in favor of #529 for now. There are a few other changes, like proper version numbers, which should happen before I try this kind of change again. |
Proposed Changes
This change declares
./src/index.js
as the "main" script inpackage.json
, and stops buildingdist/node/*
with webpack. This change also adjusts the webpack configuration for compatibility with similarly unpacked audio, render, and storage modules.Reason for Changes
This sets us up to build
scratch-gui
in a single step, allowing webpack to better optimize our files and reducing the duplication of code within our output bundles.Test Coverage
Test coverage has not changed: the tests were already using the unpacked source.